C30 · Topic 3.7 · 40 minutes · AAP-2.I
Checking nested decision paths
By the end you can:
- Enumerate all Boolean input combinations.
- Choose tests for each reachable path.
- Recognise an unreachable or contradictory branch.
Before this lesson: topics 3.6.
- Nested conditional
- A conditional statement inside a branch of another conditional.
- Reachability
- Whether a path or statement can execute under the stated conditions.
Understand
With two independent Boolean inputs there are four input combinations to consider. A path test records the conditions evaluated and the expected effect for each combination. Testing all four in this finite model covers its input combinations, but that is a bounded claim, not proof about an unrelated arbitrary programme.
A nested condition can contradict its enclosing condition. For numerical age, a branch requiring age<12 cannot be reached inside a branch already requiring age≥16. Recognising such contradictions can simplify a decision tree and reveal a misplaced condition or an incorrect assumption about the input domain.
Worked example
Inside IF(age≥16), a developer adds IF(age<12){DISPLAY("Child")} before the normal adult output.
- Entering the outer body establishes age≥16.
- The inner age<12 condition cannot be true for the same unchanged numerical age.
- The Child output is unreachable under this stated domain; more tests cannot make the contradiction true.
Explore each concept
Choose a concept, change its inputs and follow the explanation. Each example models the stated rule or scenario; completing it is practice rather than evidence of mastery.
- Outer branch before inner branch
- Unreachable conditions
- Path coverage
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
- Age (0–100)17Waiting
- Inner conditionage<12Waiting
Ready to explore: Reachable and contradictory nested paths
Why: Change an input, predict the first effect, then advance one step.
Try this: Change one input or choose another listed case. Predict the effect, reset and compare the states and governing rule.
Step through and experiment
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
- Input 1yesWaiting
- 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.
Check a misconception
Claim: If a path is never seen in tests, adding random tests must eventually reach it.
Some paths are impossible because their conditions contradict one another.
Guided practice
Give four tests covering the route selector’s Boolean combinations.
Work with a partner. Make a prediction, compare your reasoning, then identify the rule that supports your answer.
Independent transfer
Explain what changes if age is reassigned between the two numerical comparisons.
Exit check
What distinguishes path coverage from a test that checks only a final output?
Write your reasoning before comparing with a classmate. If your teacher assigned this task, submit it through My classes to save your work and receive feedback.
Check yourself
Your practice so far
Check an answer to see its rationale.