Fork me on GitHub

随笔分类 -  Algorithms

摘要:看了博客园里一篇文章《一道腾讯前端试题,谁来试试身手》,正好以前了解过位图法,确实不错。位图法适用于大规模数据,但数据状态又不是很多的情况。通常是用来判断某个数据存不存在,如可标记1为存在,0为不存在。 位图法网上资料比较少,我在百度百科找到了对它的描述位图法比较适合于如下这种情况,它的做法是按照集合中最大元素max创建一个长度为max+1的新数组,然后再次扫描原数,遇到几就给新数组的第几位置上1,如遇到 5就给新数组的第六个元素置1,这样下次再遇到5想置位时发现新数组的第六个元素已经是1了,这说明这次的数据肯定和以前的数据存在着重复。这种给新数组初始化时置零其后置一的做法类似于位图的处理方. 阅读全文
posted @ 2012-07-12 23:02 木宛哥说编程 阅读(4640) 评论(5) 推荐(3) 编辑
摘要:ZOJ ACM 2100。典型的DFS,题目: It is spring time and farmers have to plant seeds in the field. Tom has a nice field, which is a rectangle with n * m squares. There are big stones in some of the squares. Tom has a seeding-machine. At the beginning, the machine lies in the top left corner of the field. After the machine finishes one square, Tom drives it into an adjacent square, and continues seeding. In order to protect the machine, Tom will not drive it into a square that contains stones. 阅读全文
posted @ 2011-05-10 22:24 木宛哥说编程 阅读(324) 评论(0) 推荐(1) 编辑

multifunction lasers
访问人数