Questions: Queue Applications: Level-Order Traversal and Breadth-First Search

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

In BFS, a node is discovered via two different paths simultaneously. Which path is guaranteed to be shortest?

AThe path that was enqueued first, because FIFO ordering ensures earlier-discovered paths are shorter
BThere is no guarantee — BFS explores all paths and picks the shortest afterward
CThe path through the node with the fewest neighbors, because it processes faster
DBoth paths are equally short, because BFS expands in all directions simultaneously
Question 2 Multiple Choice

You modify BFS by replacing the queue with a stack. What traversal order results?

AThe same level-by-level BFS order, because the graph structure determines traversal
BDepth-first search — the stack causes deep exploration of one branch before backtracking
CRandom order — a stack does not preserve any meaningful traversal structure
DReverse BFS — nodes are visited in the opposite order from normal BFS
Question 3 True / False

In BFS on a graph, a node should be marked visited when it is dequeued, not when it is enqueued, so that most processing happens before the node is locked out.

TTrue
FFalse
Question 4 True / False

BFS guarantees that the first time any node is reached, it is via a shortest path from the source.

TTrue
FFalse
Question 5 Short Answer

Explain why using a queue (rather than a stack or any other structure) is what makes BFS explore nodes level by level.

Think about your answer, then reveal below.