大门|大门-CS-2017(第2组)|问题22

使用队列数据结构实现了呼吸优先搜索(BFS)。

null

g2017_15

以下哪一项是访问上图中节点的可能顺序。 (A) MNOPQR (B) NQMPOR (C) QMNROP (D) POQNMR 答复: (D) 说明: 在里面 BFS ,我们打印一个起始节点,然后是它的相邻节点,然后是相邻节点的相邻节点,依此类推。。

Option A : MNOPQR Wrong
We cannot visit "O" before "R" as we start from "M". 
Note that "O" is adjacent of adjacent for "M" and
"R" is adjacent of "M".

Option B : NQMPOR Wrong
We cannot visit "P" before "O" as we start from "N". 
Note that "P" is adjacent of adjacent for "N" and 
"O" is adjacent.

Option C : QMNROP Wrong
We cannot visit "R" before "O" as we start from "Q". 
Note that "R" is adjacent of adjacent for "Q" and
"O" is adjacent of "Q"

Option D : POQNMR Right
We visit "P", then its adjacent "O", "Q" and "N"
Finally we visit adjacent of adjacent "M" and "R"

这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享