阅读背景:

非递归DFS与BFS,只有堆栈与队列不同?

来源:互联网 

I am looking at the non-recursive DFS and BFS of a general graph. Besides the fact that the former uses a stack instead of a queue, the only difference is that it "delays checking whether a vertex has been discovered until the vertex is popped from the stack rather than making this check before pushing the vertex." Why is this "visited" check order different? Or put it another way, can we change BFS to non-recursive DFS by simply replacing queue in BFS with stack? o




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: