之前使用scrapy实现了一个超级简单的爬虫工具,用于抓取豆瓣上面所有的编程书籍信息(由于不需要爬取整个页面的所以链接,所以不需要用到BFS or DFS,只实现顺序抓取下一页) 这次使用的是python自带的urllib 和urllib2等python模块实现,同样以豆瓣上面的爱情电影信息作...
分类:
编程语言 时间:
2014-07-22 22:47:35
阅读次数:
347
Apparently BFS is the most obvious one.. but it is not that simple - only constant extra space is provided.Then the only strategy to take is recursion...
分类:
其他好文 时间:
2014-07-22 00:39:35
阅读次数:
258
Ignatius and the Princess ITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11700Accepted Submissio...
分类:
其他好文 时间:
2014-07-22 00:16:35
阅读次数:
264
回家后 第一题~~纯粹的 Bfs + priority_queue碰到这种 什么打个怪 多耗1min 果断都是 优先队列就和 南阳 有个 坦克大战 一样别忘了 优先队列 结构体存储时候 重写 operator 2 #include 3 #include 4 using namespace st...
分类:
其他好文 时间:
2014-07-22 00:00:36
阅读次数:
260
链接:poj 3026
题意:y行x列的迷宫中,#代表阻隔墙(不可走),空格代表空位(可走),S代表搜索起点(可走)
A代表外星人站(可走),现在要从S出发,将S和所有的A之间都连通,求路线总距离最小值
分析:可以先用bfs将所有的A,S两两之间的最短距离,题目的目的是将S与所有的A连通,使得总距离最小,
所有任选一点开始按最小生成树的算法做就行,并非非要从S点开始...
分类:
其他好文 时间:
2014-07-20 23:26:40
阅读次数:
374
关于二叉树的遍历有很多的方法, 下面介绍两个经典的遍历算法: BFS和DFS。一个是深度优先遍历, 一个是广度有优先遍历。 这两种遍历算法均属于盲目的遍历算法, 一般而言, 启发式的遍历搜索算法比较好一些。 。 关于各种遍历算法的对比, 将会在后面逐一提及。 这里不在赘述。
由于树是一个非线性的数据结构, 显然不能像linked list , 或者Array那样通过从头像最末尾移动去实现遍历每一...
分类:
编程语言 时间:
2014-07-20 23:14:21
阅读次数:
387
这里讲讲对binary Tree 进行level order Traversal.。 即BF traversal(广度优先遍历)。即首先, 访问根节点F, 打印出数据。 接着访问level 1的所有节点, 即D, J。 访问完level1之后, 访问level2, 即B, E, G , K 等等一次访问下去, 直至遍历完所有的节点。
BFS遍历的思路很简单, 但是当我们编程实现的时候,...
分类:
编程语言 时间:
2014-07-20 23:11:21
阅读次数:
344
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
For example:
Given binary...
分类:
其他好文 时间:
2014-07-20 22:41:23
阅读次数:
303
dfs 栈溢出,bfs超时,用dfs非递归就不溢出了,前后写了1一个星期class node{ int i; int j; public node(int i1,int j1) { i=i1; j=j1; ...
分类:
其他好文 时间:
2014-07-20 22:32:17
阅读次数:
244
Borg MazeDescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the ter...
分类:
其他好文 时间:
2014-07-20 22:28:43
阅读次数:
253