Skip to main content
Module 5 · Dijkstra's Algorithm

Lesson 6 · Testing and Swapping — Knowledge Checks

Name Date
  1. On a clear grid, why check the step count rather than the exact path?

    1. A.The exact path is impossible to compute
    2. B.There can be several shortest paths of the same length — Dijkstra may pick a different valid one
    3. C.Step count is easier to type
    4. D.The path is always the same

    Answer Why?

  2. In a for/else loop, when does the else block run?

    1. A.Every time, always
    2. B.Only if the loop finishes without hitting break
    3. C.Only if break is hit
    4. D.Never

    Answer Why?

  3. How many lines of the Navigator's own code change to use Dijkstra instead of Manhattan?

    1. A.Dozens — you rewrite drive_path
    2. B.Zero — only the import and constructor change; the Navigator code is untouched
    3. C.Every line that mentions a path
    4. D.You must build a new Navigator class

    Answer Why?

  4. The swap works because Dijkstra is 'better' than Manhattan. True or false?

    1. A.True — better classes are always swappable
    2. B.False — the swap works because they share the same interface, not because of quality
    3. C.True — Manhattan is broken
    4. D.False — you cannot swap classes in Python

    Answer Why?