Data Structures & AlgorithmsEasyWipro · Accenture pattern

Which data structure does breadth-first search (BFS) use to decide which vertex to visit next?

  1. A. Min-heap
  2. B. Queue
  3. C. Stack
  4. D. Hash table

Correct answer: B. Queue

BFS visits vertices in order of distance from the source, which needs FIFO order: a queue. A stack gives DFS, and a min-heap is what Dijkstra's algorithm uses.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic