Review, explain, practice

Study guide: Trace and Repair Changing Values

Track counters, assignment order and accumulated totals, then repair misplaced resets.

Download the grade study pack

Ideas to explain in your own words

Watch your reasoning

A worked review example

Trace a Repeat with a Counter: Starting at 0 and adding 2 three times gives 0 → 2 → 4 → 6. The shown result is 6; the initial value is not an extra repetition. Watch the Order of Updates: Original rows after both variables are set: (a, b) = (2, 0) → (2, 2) → (5, 2). Reordered updates give (2, 0) → (5, 0) → (5, 5). The original shows 5 and 2. Add a List into One Total: Rows: position 1, item 3, total 3; position 2, item 1, total 4; position 3, item 4, total 8. After the loop the algorithm shows 8. Find a Reset in the Wrong Place: Faulty trace: 0 → 2, reset 0 → 3, reset 0 → 4; shown 4. Repaired trace: 0 → 2 → 5 → 9; shown 9. An empty list visits no items, so the repaired result is 0.

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.