Review, explain, practice

Study guide: Build Evidence for Small Functions

Test a function’s contract, boundaries and list structure, then retain regression cases.

Download the grade study pack

Ideas to explain in your own words

Watch your reasoning

A worked review example

Choose tests that catch a rule error: Correct rule: 11 → child, 12 → standard, 13 → standard. The mistaken ≤ rule labels 12 as child, so the test 12 → standard exposes the boundary error. Test Valid and Invalid Inputs Separately: −1 → invalid; 0 → small; 3 → small; 4 → large; 8 → large; 9 → invalid; 2.5 → invalid; text "4" → invalid; Boolean true → invalid. Validity and classification are tested separately. Use a Small Test to Find a Loop Error: Faulty results: [] → 0; [5] → 0 because no positions are visited; [2,4,1] visits positions 0,1 and returns 6 instead of 7. Repaired endpoint n returns 0, 5 and 7 respectively. Repair a Function and Keep Its Test: Faulty outputs for 2,3,6,7,8: low, mid, mid, mid, high. Only 7 fails its expected high label. Repaired outputs: low, mid, mid, high, high; all five supplied tests pass.

Make a practice plan

  1. Try the supplied lesson problems without looking at the answers.
  2. Compare your method with the worked examples and explain any correction.
  3. Use the new review cases, then complete the transfer task on paper or in your own document.