GATE 2017 CS (CS2) – Question 25
BFS is implemented using a queue. Which is a possible vertex-visiting order for the shown graph?

Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (D) POQNMR
Explanation
Start at P: its distance-one neighbours are O,Q and its distance-two vertices are N,M. R is reached from M at distance three. Choosing neighbour order O,Q and then N,M produces P,O,Q,N,M,R. This is D. The other sequences place a farther vertex before a nearer one or violate queue discovery order.
More Graph Algorithms: Traversals, Minimum Spanning Trees, Shortest Paths questions
- GATE 2012 CS (CS1) Q50
- GATE 2013 CS (CS1) Q29
- GATE 2011 CS (CS1) Q64
- GATE 2011 CS (CS1) Q65
- GATE 2010 CS (CS1) Q60
- GATE 2010 CS (CS1) Q61
All Graph Algorithms: Traversals, Minimum Spanning Trees, Shortest Paths questions →