Which data structure is used to implement breadth-first search (BFS) on a graph?
-
A
Hash set
-
B
Heap
-
C
Stack
-
D
Queue
Correct answer
29 views
Explanation
BFS uses a FIFO queue to visit nodes level by level, which finds shortest paths in unweighted graphs. Depth-first search uses a stack or recursion.
Reference
Asked in: GATE CS, NTS, Technical Interviews
Doubts & discussion
Not sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ