Skip to main content
Module 5 · Pathfinding Around Obstacles

Lesson 5-4 · The Pathfinding Functions — Knowledge Checks

Name Date
  1. Why must a planner be TOLD the robot's position instead of remembering it?

    1. A.So the planner and the driving code can never disagree about where the robot is
    2. B.Because functions cannot store values between calls
    3. C.To make the path shorter
    4. D.Because the position changes while the path is being computed

    Answer Why?

  2. Why does add_blocked() not need `global BLOCKED`, when set_threshold() in Lesson 2-7 needed `global THRESHOLD`?

    1. A.append changes the list in place; set_threshold reassigns the name
    2. B.Lists are always global
    3. C.BLOCKED is in capital letters
    4. D.It does need it — the code above is wrong

    Answer Why?

  3. (1,1) is blocked. Someone wrote build_graph with the first `in blocked` check but forgot the second. What is wrong with the result?

    1. A.(1,1) is not a key, but it still appears in its neighbors’ lists — there are edges into the wall
    2. B.(1,1) is a key with an empty neighbor list
    3. C.Nothing — the first check is enough
    4. D.The graph has 16 keys instead of 15

    Answer Why?