如果在Breadth-FirstSearch(BFS)算法中使用堆栈而不是queueq,会发生什么?

时间:2014-04-08 23:26:56

标签: algorithm stack queue depth-first-search breadth-first-search

如果在广度优先搜索(BFS)算法中使用堆栈而不是queueq会发生什么?

pseudocode of BFS with queue:
    BFS(node)
    {
       queue <- node
       while queue not empty 
       v <-- queue
       print v
       for each child c of v quequ <-c
    }

1 个答案:

答案 0 :(得分:3)

在这种情况下,它成为深度优先搜索