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

Lesson 6-2 · Weights in the Graph — Knowledge Checks

Name Date
  1. SLOW_EDGES holds ((0, 1), (0, 2), 5). What do weight((0, 2), (0, 1)) and weight((1, 1), (1, 2)) return?

    1. A.5 and 5
    2. B.5 and 1 — the slow segment matches in either order; a segment not in the list is a normal block
    3. C.1 and 1
    4. D.An error, because the first pair is backwards

    Answer Why?

  2. Why does path_cost() need the position parameter, when the path is right there?

    1. A.It does not; position is unused
    2. B.The path excludes the start (Lesson 4-3's promise 1), so the first segment runs from position to path[0], and only the caller knows position
    3. C.To check the path is not empty
    4. D.Because weight() requires three arguments

    Answer Why?

  3. BFS passes every Module 5 property on the slow grid and fails only the cost check. What does that tell you?

    1. A.BFS is broken and must be rewritten from scratch
    2. B.BFS does exactly what it promises — fewest steps — and cost is a different thing it was never asked to minimize
    3. C.The harness is wrong
    4. D.The slow segment should be blocked instead

    Answer Why?