The Breadth First Search algorithm has been implemented using the queue data structure. One possible order of visiting the nodes of the following graph is

**(A)** MNOPQR

**(B)** NQMPOR

**(C)** QMNPRO

**(D)** QMNPOR

**Answer:** **(C)** **Explanation:** Option (A) is MNOPQR. It cannot be a BFS as the traversal starts with M, but O is visited before N and Q. In BFS all adjacent must be visited before adjacent of adjacent.

Option (B) is NQMPOR. It also cannot be BFS, because here, P is visited before O.

(C) and (D) match up to QMNP. We see that M was added to the queue before N and P (because M comes before NP in QMNP). Because R is M’s neighbor, it gets added to the queue before the neighbor of N and P (which is O). Thus, R is visited before O.

## Recommended Posts:

- Algorithms | Graph Traversals | Question 1
- Algorithms | Graph Traversals | Question 2
- Algorithms | Graph Traversals | Question 12
- Algorithms | Graph Traversals | Question 12
- Algorithms | Graph Traversals | Question 12
- Algorithms | Graph Traversals | Question 9
- Algorithms | Graph Traversals | Question 8
- Algorithms | Graph Traversals | Question 9
- Algorithms | Graph Traversals | Question 12
- Algorithms | Graph Traversals | Question 12
- Algorithms | Graph Traversals | Question 12
- Algorithms | Graph Shortest Paths | Question 14
- Algorithms | Graph Minimum Spanning Tree | Question 1
- Algorithms | Graph Minimum Spanning Tree | Question 2
- Algorithms | Graph Minimum Spanning Tree | Question 3
- Algorithms | Graph Minimum Spanning Tree | Question 4
- Algorithms | Graph Minimum Spanning Tree | Question 5
- Algorithms | Graph Shortest Paths | Question 2
- Algorithms | Graph Minimum Spanning Tree | Question 6
- Algorithms | Graph Shortest Paths | Question 3