Question
Official answer and solution
- Official answer
- D
- From
- Official GATE 2017 answer key
Solution
Simulate the Breadth-First Search (BFS) queue mechanics starting from each candidate vertex and check against the given visitation orders.
Let us check each option:
- Option A (MNOPQR): Starts at . The neighbors of are . After visiting and its neighbor , the remaining unvisited neighbors at distance 1 ( and ) must be visited before any distance-2 vertex. However, (distance 2 from ) is visited before and , violating BFS.
- Option B (NQMPOR): Starts at . The neighbors of are . After visiting and , the remaining neighbor at distance 1 must be visited before (distance 2). Visiting before violates BFS.
- Option C (QMNROP): Starts at . The neighbors of are . Vertex is at distance 2 from (via ). Visiting before and violates BFS.
- Option D (POQNMR):
- Start at vertex . Visit , enqueue neighbors of : , then . Visited order: .
- Dequeue . Neighbors of are (unvisited), (already queued), (visited). Enqueue . Visited order: .
- Dequeue . Neighbors of are (unvisited), (already queued), (visited), (visited). Enqueue . Visited order: .
- Dequeue . Unvisited neighbors: none. Visited order: .
- Dequeue . Unvisited neighbor is . Enqueue . Visited order: .
- Dequeue . Queue empty. Visited order: .
The sequence POQNMR is a strictly valid BFS traversal order, matching option D.
Final answer
D
Common trap
Confusing BFS with DFS or visiting nodes across levels out of FIFO queue order.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 2
- Question
- 15 of 65, printed as CS Q.15
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.