Skip to main content
Module 6 · Dijkstra's Algorithm (optional)

Lesson 6-1 · When Fewest Steps Isn't Fastest — Knowledge ChecksAnswer key

Correct answers are marked and the explanation follows each question.

  1. Why does compute_bfs_path() choose the slow road without hesitation?

    1. A.It has a bug
    2. B.It counts steps, and the slow road is one step like any other — the graph has no way to say an edge is long✓
    3. C.It prefers rows to columns
    4. D.It always chooses the first neighbor in the list

    BFS finds the path with the fewest edges. Nothing in the graph or the planner knows one edge takes longer to drive than another. That information does not exist yet — this module adds it.

  2. A normal block takes 4 seconds and the slow segment takes 16. What is its weight?

    1. A.16
    2. B.4 — it costs four normal blocks' worth of time✓
    3. C.12
    4. D.0.25

    weight = slow time / normal time = 16 / 4 = 4. A weight is measured in blocks, not seconds, so the same number works whatever speed the robot drives at.

  3. With the slow segment at weight 5, which route does BFS choose from (0,0) to (0,3), and what does it cost?

    1. A.Route B, cost 5 — BFS finds the cheapest path
    2. B.Route A, cost 7 — BFS finds the fewest steps, and A has 3 steps to B's 5✓
    3. C.Route A, cost 3
    4. D.Neither; it reports no path

    BFS compares 3 steps against 5 steps and takes 3. It never sees the 7, because cost is not something it computes. The robot pays the extra time on the floor.

  4. The slow segment measures weight 3. From (0,0) to (0,3), what happens?

    1. A.The detour is faster by 2
    2. B.The straight route costs 1+3+1 = 5 and the detour costs 5 — a tie, so the slow road is not slow enough to change the answer✓
    3. C.The straight route is faster by 2
    4. D.BFS reports no path

    Going round one segment costs three normal blocks on an open grid, so weight 3 exactly breaks even. The module needs the slow segment to be worse than that.