Recall & Review
beginner
What does BFS stand for and what is its main use in graphs?
BFS stands for Breadth-First Search. It is mainly used to explore nodes level by level and find the shortest path in unweighted graphs.
Click to reveal answer
beginner
Why is BFS suitable for finding the shortest path in an unweighted graph?
Because BFS explores neighbors in layers, the first time it reaches a node, it has found the shortest path to that node.
Click to reveal answer
beginner
In BFS for shortest path, what data structure is commonly used to keep track of nodes to visit next?
A queue is used to keep track of nodes to visit next, ensuring nodes are processed in the order they are discovered.
Click to reveal answer
intermediate
What additional information do we store during BFS to reconstruct the shortest path?
We store the parent or predecessor of each node, so after BFS finishes, we can trace back from the target node to the start node.
Click to reveal answer
intermediate
What is the time complexity of BFS when finding the shortest path in an unweighted graph?
The time complexity is O(V + E), where V is the number of vertices and E is the number of edges, because each node and edge is processed once.
Click to reveal answer
What data structure does BFS use to explore nodes in order?
✗ Incorrect
BFS uses a queue to explore nodes level by level.
In an unweighted graph, BFS finds the shortest path because it:
✗ Incorrect
BFS explores nodes layer by layer, so the first time it reaches a node, it is via the shortest path.
Which of these is NOT needed to reconstruct the shortest path after BFS?
✗ Incorrect
Node color coding is not required for path reconstruction; parent tracking is essential.
What is the initial step in BFS for shortest path?
✗ Incorrect
BFS starts by adding the start node to the queue and marking it visited.
What is the time complexity of BFS in terms of vertices (V) and edges (E)?
✗ Incorrect
BFS visits each vertex and edge once, so time complexity is O(V + E).
Explain how BFS finds the shortest path in an unweighted graph step-by-step.
Think about how BFS explores nodes layer by layer.
You got /5 concepts.
Describe how to reconstruct the shortest path after BFS completes.
Trace back from the end node to the start using parents.
You got /4 concepts.