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

Lesson 6-5 · Three Planners, One Harness — Knowledge ChecksAnswer key

Correct answers are marked and the explanation follows each question.

  1. Where does the slow-edge list live in the class version, and why?

    1. A.In a global SLOW_EDGES, as in Lesson 6-2
    2. B.Inside the Dijkstra object as self.slow_edges, like self.blocked — it is the planner's own knowledge of the grid, reached only through add_slow_edge()✓
    3. C.Inside the harness
    4. D.In the Navigator

    A class keeps its data with the methods that use it. The blocked list moved inside BFS in Lesson 5-5 for the same reason; the slow list follows it.

  2. Why must BFS have an add_slow_edge() method that does nothing?

    1. A.Python requires every class to have the same methods
    2. B.So the harness can call planner.add_slow_edge() on whichever planner it holds without checking which one — the same reason Manhattan has an add_blocked() that does nothing✓
    3. C.Because BFS secretly uses weights
    4. D.It does not; the harness skips BFS

    The harness is written against the shape. A planner that cannot use a piece of information still has to accept it, or the harness would need an if for every class — which is exactly what polymorphism avoids.