You've designed programs. Now watch them run, trace their state, work out what they do, and fix them when they break. Standard methods, trace tables, the purpose of an algorithm, and finding and correcting errors — four skills Paper 2 regularly tests.
Read this before you tap the activities. These notes give you everything you need to feel confident before the Trace Table Runner and Bug Hunter. When you're ready, tap 🎓 Learn.
In the Development Lifecycle lab you designed programs. Now you'll run them. That means recognising the standard methods in the syllabus (linear search, bubble sort, totalling, counting, and finding the maximum, minimum and average), tracing an algorithm step by step in a trace table, stating an algorithm's purpose and describing its processes, and finding and correcting errors. Trace-table questions appear regularly on Paper 2 — careful tracing is hard to bluff.
By the end of this lab you should be able to…
| Term | One-line definition |
|---|---|
| Algorithm | A sequence of steps to solve a problem. |
| Trace table | A table used to step through an algorithm and record every variable value. |
| Linear search | Check each element in turn until the target is found or the list ends. |
| Bubble sort | Compare adjacent pairs; swap if out of order; repeat until no swaps. |
| Counting | Using a counter variable to count how many times something occurs (e.g. how many pass a test). |
| Totalling | Using a totaller variable to keep a running total (also called an accumulator). |
| Iteration | Repeating steps in a loop; one pass of a loop is also called an iteration. |
| Nested loop | A loop inside another loop (bubble sort's core pattern). |
| Flag | A BOOLEAN variable that signals "done" or "found" — often used to exit a loop early. |
| Syntax error (useful background) | Code that breaks the rules of the language (missing ENDIF, wrong keyword). |
| Logic error | Code that runs but produces the wrong result (> instead of >=). |
| Runtime error | Code that fails while running (dividing by zero, array out of bounds). |
| Method | What it does | Core pattern |
|---|---|---|
| Linear search | Check each element in turn; stop when found | Loop + IF + flag |
| Bubble sort | Repeatedly compare and swap adjacent pairs | Nested loop + swap |
| Totalling | Keep a running total | Total ← Total + Value |
| Counting | Count how many items match | Count ← Count + 1 |
| Max | Track the largest value seen | Loop + IF (>) |
| Min | Track the smallest value seen | Loop + IF (<) |
| Average | Sum + count then divide | Totaller ÷ counter |
| Type | Meaning | Example |
|---|---|---|
| Syntax | Breaks the language rules | Missing ENDIF; NEXT j when the loop was FOR i |
| Logic | Code runs but gives wrong result | Using > when you meant >=; outputting the wrong variable |
| Runtime | Fails during execution | Dividing by zero; accessing Array[11] in a 10-element array |
Given Numbers = [23, 41, 17, 88, 5] and this algorithm:
Max ← Numbers[1]
FOR i ← 2 TO 5
IF Numbers[i] > Max
THEN
Max ← Numbers[i]
ENDIF
NEXT i
OUTPUT Max
The trace table:
| i | Numbers[i] | Max | Output |
|---|---|---|---|
| 23 | |||
| 2 | 41 | 41 | |
| 3 | 17 | ||
| 4 | 88 | 88 | |
| 5 | 5 | ||
| 88 |
Note: no quotation marks on 88. Blank cells where variables don't change.
Count ← 0
FOR i ← 1 TO 30
INPUT Score
IF Score >= 50
THEN
Count ← Count + 1
ENDIF
NEXT i
OUTPUT Count
State the purpose (one sentence): It counts how many of 30 input scores are 50 or greater (i.e. how many passed).
Describe the processes (the steps): Count is set to 0; a loop runs 30 times; each time a score is input and, if it is 50 or more, 1 is added to Count; after the loop Count is output.
Notice the pattern: Count is a counter. The IF is a filter. Loop 30 times = process 30 items.
The trace table Output column stores values, not strings-as-text. Write Found at 3, not "Found at 3". Examiners deduct for the quotes.
Once the algorithm's stopping condition is met, no further rows go in the trace table. A WHILE that exits at i=6 doesn't get a row for i=7.
"It sets Count to 0, then loops from 1 to 30…" is reading the code back, not stating its purpose. Say what it does: "It counts how many scores are ≥ 50." But if the question says describe the processes, then you do explain the main steps.
Bubble sort needs a nested loop: outer for passes, inner for comparisons. A single loop sorts only one pair, not the whole list.
Leave the cell blank — but don't remove the row. Every iteration gets a row; unchanged variables just don't get a value.
Mark-winning tips distilled from the 2023–2025 examiner reports:
Tap each question to reveal the answer. Aim for at least 5 of 6.
Name the standard methods. Follow every trace-table rule (record every assignment, outputs and prompts, no quotes on outputs, stop at loop exit). State an algorithm's purpose in one sentence, and describe its processes when asked.
Ready? Tap the 🎓 Learn tab and try the Trace Table Runner — step through three real algorithms and watch the variables update live.
The syllabus lists a small set of standard methods: linear search (check each item until found), bubble sort (repeatedly compare and swap adjacent pairs), totalling, counting, and finding the maximum, minimum and average. All of them can be tested by tracing — stepping through the code with sample data and recording every variable, output and prompt in a table. If you can trace it, you understand it. Trace tables also help you work out the purpose of an unfamiliar algorithm and find the errors in a faulty one. Get comfortable with tracing and this whole section opens up.
Grab a pen and paper. Copy the Max algorithm from Book Notes. Pick your own array of 5 numbers. Draw a trace table with columns for i, Numbers[i], Max, Output. Step through by hand — one row per iteration. If your Max ends as the largest number in your list, you've done it right. That's the skill trace-table questions test.
Debuggers in real IDEs (VS Code, PyCharm, Visual Studio) are essentially live trace tables. You set a breakpoint, run the program, and the IDE shows you every variable's current value, stepping through one instruction at a time. Learning trace tables is learning how to think like a debugger — a skill you'll use every day as a professional programmer.
Bubble sort is famously inefficient on large data (O(n²)) — modern languages use quicksort or Timsort instead. So why does Cambridge still teach bubble sort? What is the educational value of an "inefficient" algorithm?
Exam questions ask you to identify the error (usually by line number) and suggest a correction. Knowing the type of error helps you find it, but naming the type is not required by the syllabus.
What: code that breaks the language rules.
When: found by the translator — a compiler reports it before the program runs; an interpreter stops when it reaches that line.
Examples: missing ENDIF, NEXT j when the loop is FOR i, misspelled keyword.
What: code that runs but produces the wrong answer.
When: only visible when you test with data.
Examples: > where you meant >=, outputting the wrong variable, off-by-one in a loop range.
What: code that fails while running.
When: program crashes mid-execution.
Examples: dividing by zero, accessing Array[11] in a 10-element array, reading a file that doesn't exist.
Pick an algorithm, click Step, watch the current line highlight and the trace table build up. Values from the same pass share a row; a cell stays blank when nothing changes. This is the skill trace-table questions test.
The standard methods in the syllabus, in the syllabus pseudocode style. Learn to spot them at a glance. (N stands for the number of items.)
The Output column stores values, not strings. Write Found at 3, not "Found at 3". Examiner reports flag the quotes.
Once the stopping condition is met, no further rows go in the trace table. A WHILE that exits at i=6 doesn't get a row for i=7.
Cited: 2025 s25 · 2024 w24"When tracing an algorithm, each time a variable has a value assigned to it, this needs to be recorded in the trace table." — Cambridge examiner report 2024 w24.
Cited: 2024 w24 examiner report"State the purpose" wants the overall goal in one sentence — "It counts how many scores pass" — not a walkthrough of every line. (If the question says "describe the processes", then explain the main steps.)
Cited: 2023 w23 Q4(b), 2024 s24 Q3(b)"Some attempts at the bubble sort only used one loop" — 2024 w24. One pass is not enough: use an outer loop (or a flag loop) for the passes and an inner loop for the comparisons.
Cited: 2024 w24 Q12"Many candidates identified the same error twice with the switching of the Yes and No on one of the decision boxes." When correcting errors, count the DISTINCT bugs, not the same bug from two angles.
Cited: 2024 w24 examiner reportA pseudocode snippet is shown. Which standard method is it?
Given the current state of a trace and the next instruction, what value comes next?
An error is described. Is it a syntax, logic, or runtime error? (Useful background — it helps you find errors.)
A short algorithm is shown. Pick the one-sentence statement of its purpose.
Rapid questions on algorithms, tracing and errors — answer as many as you can in 60 seconds.
Cambridge-style questions modelled on Paper 2 (2023–2025) and the examiner reports — the tag shows the paper each is based on. Each question includes the algorithm you need. Type your answer, then mark it.
The Output column stores values, not string literals. Never wrap outputs in quotes.
2025 s25 · 2024 w24 (identical wording)Once the stopping condition is met, no further rows go in the trace table.
2025 s25 · 2024 w24Every time a variable is assigned, record it. Even if the value looks the same.
2024 w24 examiner reportIf the question gives 5 inputs, trace all 5. Do not stop after the first.
2025 s25 Q9State the purpose = ONE sentence on the overall goal. Describe the processes = the main steps. Read which one the question asks for.
2023 w23 Q4(b), 2024 s24 Q3(b)One pass is not enough. Outer loop (or flag loop) for the passes, inner loop for the comparisons.
2024 w24 Q12A decision box with swapped Yes/No labels is ONE error, not two. Count distinct bugs.
2024 w24 examiner reportSQL keywords (ASC, DESC, ORDER BY) belong in database queries — not in sort pseudocode.
2024 w24 examiner reportThe syllabus says a trace table records variables, outputs and user prompts at each step. A prompt such as Enter a score goes in the Output column (no quotes).
Syllabus 7.7A WHILE that never reaches its terminal condition runs forever. Always check that the loop variable is modified inside the loop.
2024 w24 examiner reportThe standard methods.
Linear search · Bubble sort · Totalling · Counting · Maximum · Minimum · Average.
The three error types (useful background).
Syntax (breaks the language rules) · Logic (wrong answer) · Runtime (fails while running).
The trace-table checklist.
1. Record every assignment. 2. Record outputs and prompts. 3. No quotes on outputs. 4. Stop when the algorithm stops. 5. Blank cells for unchanged variables.
Repeated passes + swap.
Outer loop = passes. Inner loop = adjacent comparisons. IF out of order → swap using a Temp variable. Common improvement: a flag that stops when a pass makes no swaps.
Purpose vs processes.
State the purpose: "It counts how many scores pass" ✓
Describe the processes: "Count is set to 0, a loop inputs 30 scores, 1 is added to Count for each score ≥ 50, then Count is output" ✓
Green = secured (≥70%). Yellow = focus (30–69%). Grey = not attempted. Tap any badge to override.
When you finish this lab, Topic 7 Algorithm Design & Problem-Solving is complete: the development life cycle, design methods, validation, verification and test data, plus the standard methods, trace tables and finding errors. Next is Topic 8: Programming.