由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - An interview question
相关主题
[合集] huge map怎么算最短路径?算法问题。
问问Boost library, 尤其是Boost Graph Library (BGL)烤树题。
请教一个graph问题这个题目能否半小时完成coding?
Weighted Graph Challenge 一道面试题面题:copy directed graph
shortest path algorithm(dijkstra)的变形问个关于数组的问题
C++如何实现graph?good GUI for graph layout and flow?
[算法] word ladder problem (转载)A Problem on MST
请教一个算法题关于shortest path的counting signed triad in a large-scale graph?
相关话题的讨论汇总
话题: bfs话题: dijkstra话题: node话题: interview话题: path
进入Programming版参与讨论
1 (共1页)
m********g
发帖数: 9
1
During a phone interview, I was asked how to implement a BFS algorithm to
find the shortest distance path from node A to node B in a graph. I asked is
it Dijkstra, and he said no.
Isn't BFS a special case of Dijkstra when there is no weight?
Strange.
r***r
发帖数: 153
2
结果一样,但是Dijkstra成本高很多阿
BFS is O(|E|+|V|)
Dijkstra 有很多的priority queue操作,
如果用简单的堆实现,需要 O(|V|^2)
用复杂的Fibonacci heap,(可以得到最优complexity,但没有很多实际意义)也是 O
( |E| + |V| log |V| )

is

【在 m********g 的大作中提到】
: During a phone interview, I was asked how to implement a BFS algorithm to
: find the shortest distance path from node A to node B in a graph. I asked is
: it Dijkstra, and he said no.
: Isn't BFS a special case of Dijkstra when there is no weight?
: Strange.

c*****t
发帖数: 1879
3
For BFS to work on shortest path, there are restrictions on the path
weight. Otherwise, case like
1.1 1.1 1.1 5
A---- D --- E ----- F - G
\10 /1
B-----------------
would be screwed up. In this case, one has to use Dijkstra.

O

【在 r***r 的大作中提到】
: 结果一样,但是Dijkstra成本高很多阿
: BFS is O(|E|+|V|)
: Dijkstra 有很多的priority queue操作,
: 如果用简单的堆实现,需要 O(|V|^2)
: 用复杂的Fibonacci heap,(可以得到最优complexity,但没有很多实际意义)也是 O
: ( |E| + |V| log |V| )
:
: is

b******n
发帖数: 592
4
Why?
Is BFS a full search?

【在 c*****t 的大作中提到】
: For BFS to work on shortest path, there are restrictions on the path
: weight. Otherwise, case like
: 1.1 1.1 1.1 5
: A---- D --- E ----- F - G
: \10 /1
: B-----------------
: would be screwed up. In this case, one has to use Dijkstra.
:
: O

c*****t
发帖数: 1879
5

http://www.cs.mcgill.ca/~cs251/OldCourses/1997/topic29/

【在 b******n 的大作中提到】
: Why?
: Is BFS a full search?

b******n
发帖数: 592
6
Didn't find bfs on the webpage. bfs and dfs terms have been used in speech
recognition, that's where I get my idea of it from. I checked the wiki,
seems bfs will return when target node is found. It is easy to modify the
behaviour in implementation though. So the search only ends when the costs
of other node in the queue are larger than the found target node.
Thanks for the page though/

【在 c*****t 的大作中提到】
: 见
: http://www.cs.mcgill.ca/~cs251/OldCourses/1997/topic29/

c*****t
发帖数: 1879
7
... It talked about BFS on the very top of page. Also has 2 figures...
With BFS, one has to "walk" along the edges in uniform speed to prevent
a node from updated with newer, shorter path.

【在 b******n 的大作中提到】
: Didn't find bfs on the webpage. bfs and dfs terms have been used in speech
: recognition, that's where I get my idea of it from. I checked the wiki,
: seems bfs will return when target node is found. It is easy to modify the
: behaviour in implementation though. So the search only ends when the costs
: of other node in the queue are larger than the found target node.
: Thanks for the page though/

1 (共1页)
进入Programming版参与讨论
相关主题
counting signed triad in a large-scale graph?shortest path algorithm(dijkstra)的变形
Re: 请教一道题目C++如何实现graph?
请问这道题怎么解决?[算法] word ladder problem (转载)
HW Question: Bipartite Graphs请教一个算法题关于shortest path的
[合集] huge map怎么算最短路径?算法问题。
问问Boost library, 尤其是Boost Graph Library (BGL)烤树题。
请教一个graph问题这个题目能否半小时完成coding?
Weighted Graph Challenge 一道面试题面题:copy directed graph
相关话题的讨论汇总
话题: bfs话题: dijkstra话题: node话题: interview话题: path