Which of the following is useful in traversing a given graph by Breadth-First…
20182018
Which of the following is useful in traversing a given graph by Breadth-First Search (BFS)?
Answer: D. Queue — Correct data structure: Queue (FIFO) . Why: BFS explores nodes level by level. A queue (first-in, first-out) ensures that nodes discovered earlier are…
- A.
Stack
- B.
Set
- C.
List
- D.
Queue
Attempted by 1843 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.
Loading lesson…