Which graph traversal algorithm uses a queue data structure?

Options

  • A. DFS
  • B. BFS
  • C. Binary Search
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. BFS

Detailed Explanation

Breadth-First Search (BFS) uses a queue to visit vertices level by level. The first discovered vertex is processed first, following the FIFO principle. BFS is particularly useful for finding the shortest path in an unweighted graph. It starts from a source vertex, visits its adjacent vertices, and then continues with vertices at the next level. A visited array or set is commonly used to avoid repeated processing.