Skip to main content
AP CSP course

F10 · Topic 3.7

Nested route selector

Trace a decision inside each weather branch and enumerate all reachable paths in a fictional campus route model.

1. Predict first

If wet then choose Covered ramp when stepFree is true, otherwise Covered stairs; if dry choose Outdoor ramp when stepFree is true, otherwise Outdoor steps. Predict wet=true,stepFree=false.

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 1yesWaiting
  2. Input 2noWaiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Try all four yes/no combinations. These fictional labels are not accessibility guarantees.

2. Build your procedure

Write the nested conditionals, label the four paths and give one test for each. Explain why testing only wet cases misses half the tree.

Use AP CSP pseudocode, a language you know, or precise plain language. Your code is not executed here. Use the classroom assignment to save your response.

3. Check boundaries

Public worked tests for the fixed model
InputExpectedWhy this case
wet yes; stepFree noCovered stairsInner false branch inside outer true branch.
wet no; stepFree yesOutdoor rampInner true branch inside outer false branch.
wet yes; stepFree yesCovered rampBoth conditions true.

4. Explain and reflect

Why do two separate IF statements not always have the same behaviour as this nested IF/ELSE tree?

Model limits: A fixed fictional decision tree, not live weather, a map or an accessibility guarantee. Real route suitability requires reliable local information.

Teacher guidance and scoring