Skip to main content
Module 5 · Pathfinding Around Obstacles

Lesson 5-3 · From Pencil to Program — Knowledge Checks

Name Date
  1. On a 3×3 grid, how many neighbors does the interior node (1,1) have?

    1. A.2
    2. B.3
    3. C.4
    4. D.8

    Answer Why?

  2. After (1,1) is blocked, how many neighbors does (0,1) have?

    1. A.3 — nothing changed
    2. B.2 — it lost its connection to the right, to (1,1)
    3. C.4
    4. D.0

    Answer Why?

  3. In our graph dictionary, what are the keys and what are the values?

    1. A.Keys are numbers; values are strings
    2. B.Keys are (x, y) node tuples; values are lists of neighbor tuples
    3. C.Keys are lists; values are tuples
    4. D.Both are single integers

    Answer Why?

  4. Given distance = {(2,2): 0, (1,2): 1}, what does (1,2) in distance return, and what does it mean?

    1. A.True: (1,2) already has a number
    2. B.False: (1,2) is blocked
    3. C.1: its number
    4. D.A KeyError

    Answer Why?