FutureLogic Lesson → Algorithms → Cambridge IGCSE 0478

How to Complete a Trace Table Without Losing Marks

A trace table is not a mysterious grid you fill in by guessing. It is you, becoming the computer — running an algorithm one line at a time. This lesson teaches a repeatable method that works every time.

How to Complete a Trace Table Without Losing Marks

Trace tables feel harder than they are. Students often treat them as puzzles to be solved by intuition, then panic when the numbers do not come out right. But a trace table is not a puzzle at all.

A trace table is simply you becoming the computer: read one instruction, execute it, record what changed, move on.

That is the entire skill. No jumping ahead, no solving the final answer in your head — just working through the algorithm one honest step at a time.

⏱ Estimated time: 15–18 minutes
🎯 Level: Cambridge IGCSE 0478
📚 Pairs with the Topic 7 revision notes

Before we begin…

If trace tables make you nervous, it is usually because you are trying to predict the answer instead of following the steps. The table exists precisely so you do not have to hold everything in your head.

Trust the method. Do exactly what each line says, write down the change, and the correct answer appears on its own.

By the end of this lesson, you will be able to:

Explain what a trace table records.
Set up the correct columns.
Trace a loop with a running total.
Handle an IF statement correctly.
Use the six-step FutureLogic method.
Avoid the classic tracing mistakes.

A first example

Here is a short algorithm that adds up four numbers.

Total ← 0 FOR Count ← 1 TO 4 INPUT Number Total ← Total + Number NEXT Count OUTPUT Total

We will trace it with the inputs 5, 3, 7, 2. Read one line, do exactly what it says, and record the change.

CountNumberTotal
155
238
3715
4217

Two things are worth pausing on. First, Total starts at 0 because the algorithm sets it there before the loop — if you forget that line, every row afterwards is wrong. Second, Total persists between iterations: each row carries forward the value from the row above and adds the new number. The output is the final value, 17.

Golden Rule: always write the initial values first. Most trace-table errors are not tracing errors at all — they are missing starting values.

Adding selection: an IF statement

Now let us make it harder. Suppose the algorithm also counts how many inputs are greater than 5.

IF Number > 5 THEN CountHigh ← CountHigh + 1 ENDIF

The crucial rule with selection is this: only update a variable when the statement that changes it actually executes. If Number > 5 is false, the line inside the IF does not run, so CountHigh does not change on that row. Using our inputs 5, 3, 7, 2, only 7 is greater than 5, so CountHigh increases exactly once.


The FutureLogic method

Use the same six steps every time. It turns any trace table into a routine you can follow without stress.

StepWhat to do
1. InitialiseWrite down every starting value before the algorithm runs.
2. Read one lineLook at a single instruction. Do not mentally jump ahead.
3. ExecutePerform exactly what that instruction says — nothing more.
4. UpdateChange only the variables that this instruction affects.
5. RecordWrite the new values into the correct row of the table.
6. RepeatMove to the next instruction and go again until the algorithm ends.

A note on the type of loop

The same method works whatever the loop, but watch when the loop ends. A FOR loop runs a fixed number of times, so you know in advance how many rows you will fill. A WHILE or REPEAT…UNTIL loop runs until a condition changes, so you must check that condition on every pass and keep going until it is met — not for a number of rows you assumed at the start. Reading the condition each time, rather than guessing the loop length, is what keeps a conditional trace accurate.

Exam Tip: let the table do the thinking

Do not erase your working and try to “solve” the final answer mentally. The whole purpose of a trace table is to expose how values change over time. Every row records the algorithm running step by step. In exam questions, intermediate values may be required as well as the final output.

Common mistakes to avoid

Common Mistakes:
  • Forgetting the initial values before the loop starts.
  • Updating a variable when an IF condition is false.
  • Incrementing a counter at the wrong time in the loop.
  • Losing a running total between iterations instead of carrying it forward.
  • Skipping iterations when the loop should still be running.
  • Confusing a variable’s current value with its previous value.

Retrieval Challenge

Trace this algorithm with the inputs 4, 9, 2. Fill in your own table for Count, Number and Largest, then reveal the answer.

Largest ← 0 FOR Count ← 1 TO 3 INPUT Number IF Number > Largest THEN Largest ← Number ENDIF NEXT Count OUTPUT Largest
Check the answer
CountNumberLargest
144
299
329

Largest starts at 0. It updates to 4, then to 9. On the last row, 2 is not greater than 9, so Largest stays 9. The output is 9.

Final Summary

What it is

Executing an algorithm by hand, one line at a time.

Start here

Write every initial value before the algorithm runs.

Selection

Only update a variable when its statement actually executes.

Exam Success

Show every row. Intermediate values earn marks; do not solve mentally.

When you stop guessing the answer and start running the algorithm, trace tables become the easiest marks on the paper.
FutureLogic Education

Computer Science should feel clear, visual and achievable.

Download free revision PDFs, explore the Learning Hub, or try FutureLogic resources designed to help students move from confusion to confidence.