What does the previous dictionary store?
- A.The distance from the start to each node
- B.Which node you came from to reach each node — used to rebuild the path
- C.The list of blocked nodes
- D.How many neighbors each node has
Answer Why?
Which unvisited node does Dijkstra visit next?
- A.The one closest to the destination
- B.The one with the smallest known distance from the start
- C.The most recently updated one
- D.A random one
Answer Why?
At step 7, visiting (2,1) offers (2,2) a distance of 3+1=4, but (2,2) already has distance 4. What happens?
- A.(2,2) is updated to 4 again
- B.No change — the new distance is not smaller than the existing one
- C.The algorithm crashes
- D.(2,2) is marked visited early
Answer Why?
Why must the reconstructed path be reversed?
- A.To make it look nicer
- B.Because tracing previous goes from destination back to start — reversing puts it in start-to-destination order
- C.Dijkstra always returns paths backward by mistake
- D.It doesn't need to be reversed
Answer Why?
On a clear grid with no obstacles, how does Dijkstra's path length compare to Manhattan's?
- A.Always shorter
- B.The same length (the exact route may differ)
- C.Always longer
- D.Unpredictable
Answer Why?