← Computer Science

Trace tables and dry runs

A trace table shows what an algorithm really does, one step at a time. This unit shows how to set one up and complete it for a worked example in Cambridge-style pseudocode.

Slide 1 / 4

What a dry run is

A trace table: one column per variable, plus output CountMarks[Count]TotalOUTPUT01??2?? Work line by line. Write each new value as it changes.
  • A dry run means working through an algorithm by hand, one line at a time, without a computer.
  • A trace table records the dry run. It has one column for each variable and one for output.
  • At each step you write down any value that changes, plus any output or user prompt.
  • Trace tables show what an algorithm outputs and help you find logic errors.

Check you've got it

0/4

1. In the worked example, what is the value of Total straight after the loop pass where Count = 3?

2. Why is Marks[4], which is 50, not added to Total?

3. What is the main purpose of a trace table?

4. X ← 1, then FOR I ← 1 TO 3, X ← X * 2, NEXT I, then OUTPUT X. What is output?

Practise exam-style questions on this

Type your answer, see your mark against the mark scheme in seconds. Free, 5 a day.

Start practising →

Teaching this topic?

Mark your whole class's answers and see who's stuck, for £19 a month.

See the class plan →

Free revision content. Multiple-choice answers are marked instantly. Written answers are marked by AI on /free-mark. Independent, not endorsed by Cambridge International.