📜  门| GATE-CS-2017(Set 2)|问题22

📅  最后修改于: 2021-06-29 05:41:42             🧑  作者: Mango

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

g2017_15

以下哪一项是访问上图中的节点的可能顺序。
(A) MNOPQR
(B) NQMPOR
(C) QMNROP
(D) POQ核磁共振答案: (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"

这个问题的测验