在阅读有关 DFS 与 BFS 的文章时,我发现 DFS 比 BFS 更快,并且需要更少的内存。
我的实现都是用 C++ 实现的,为 DFS 制作一个堆栈,为 BFS 制作一个队列。有人可以解释一下,速度和内存要求有何不同?
graph-theory breadth-first-search depth-first-search data-structures
breadth-first-search ×1
data-structures ×1
depth-first-search ×1
graph-theory ×1