Which of the following is useful in traversing a given graph by Breadth-First…
2018
Which of the following is useful in traversing a given graph by Breadth-First Search (BFS)?
- A.
Stack
- B.
Set
- C.
List
- D.
Queue
Attempted by 1375 students.
Show answer & explanation
Correct answer: D
Correct data structure: Queue (FIFO) . Why: BFS explores nodes level by level. A queue (first-in, first-out) ensures that nodes discovered earlier are processed before nodes discovered later, producing the breadth-first order. Initialize the queue with the start node and mark it visited.