Which of the following data structure is useful in traversing a graph by breadth-first search?
4 views
1 Answers
Option 2 : Queue
Breadth First Search uses a queue (First In First Out) and Depth first search uses a stack (First In Last Out).
BFS checks whether a vertex has been discovered before enqueueing the vertex rather than delaying this check until the vertex is dequeued from the queue.
4 views
Answered