Which of the following data structure is useful in traversing a given graph by…

2017

Which of the following data structure is useful in traversing a given graph by breadth first search?

  1. A.

    Stack

  2. B.

    List

  3. C.

    Queue

  4. D.

    None of the above.

Attempted by 635 students.

Show answer & explanation

Correct answer: C

Breadth First Search (BFS) traverses a graph level by level. To maintain the order of visiting nodes, it uses a Queue data structure which follows the First-In-First-Out (FIFO) principle. This ensures that all neighbors of a node are explored before moving to the next level.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Isro