Docs

Topic 7 · Algorithm design and problem-solving

Test data and trace tables

Normal, abnormal, extreme, and boundary test data, and how to trace an algorithm one line at a time.

Lesson 5 of 5Syllabus 7.6–7.8updated October 31, 2026

Types of test data

To test a program properly you need several kinds of data. Take a program that accepts whole-number percentages from 0 to 100:

TypeMeaningExamples for 0–100Expected result
NormalOrdinary data that should be accepted45, 72Accepted
AbnormalData that should be rejected−20, 150, "abc"Rejected
ExtremeThe largest and smallest values that should be accepted0, 100Accepted
BoundaryThe values at each limit and just beyond it0 and −1, 100 and 1010 and 100 accepted, −1 and 101 rejected

Exam tip. For boundary data, always give a pair: the last accepted value and the first rejected value.

Trace tables

A trace table records the value of every variable as an algorithm runs, line by line. It lets you check what an algorithm does, find logic errors, and work out its output without a computer.

Here is an algorithm that adds up only the positive numbers it is given. Step through its trace with the inputs 5, −2, 7, 3.

Pseudocode
DECLARE Total : INTEGER
DECLARE Count : INTEGER
DECLARE Number : INTEGER
Total <- 0
FOR Count <- 1 TO 4
    INPUT Number
    IF Number > 0
      THEN
        Total <- Total + Number
    ENDIF
NEXT Count
OUTPUT Total
Trace table, inputs 5, −2, 7, 3
CountNumberTotalOUTPUT
0
155
2−25
3712
4315
15
Step 1 / 6
When the input is −2 the condition is false, so Total stays at 5.

Finding errors

A syntax error breaks the rules of the language, such as a missing ENDIF, and stops the program being translated. A logic error lets the program run but gives the wrong result.

This algorithm should output the largest of 10 numbers, but it has a logic error. Can you spot it?

Pseudocode
DECLARE Largest : INTEGER
DECLARE Number : INTEGER
DECLARE Count : INTEGER
Largest <- 0
FOR Count <- 1 TO 10
    INPUT Number
    IF Number < Largest
      THEN
        Largest <- Number
    ENDIF
NEXT Count
OUTPUT Largest

Watch out. The comparison should be Number > Largest. Also, starting Largest at 0 fails if every number is negative. Starting with the first number input is safer.

Key terms

Normal data
Data within the accepted range that should be accepted.
Abnormal data
Data that should be rejected.
Extreme data
The largest and smallest values that should be accepted.
Boundary data
Values at the edge of the accepted range and just outside it.
Trace table
A table that records variable values as an algorithm runs.
Logic error
An error that lets a program run but produces the wrong result.

Check yourself

A program accepts ages 11 to 18. Give boundary test data.Show answer

10 and 11 (lower), 18 and 19 (upper). 11 and 18 are accepted, 10 and 19 rejected.

Is "twelve" normal, abnormal, extreme, or boundary data for an age field?Show answer

Abnormal: it is the wrong data type and should be rejected.

What is the difference between a syntax error and a logic error?Show answer

A syntax error breaks the language rules so the code will not translate. A logic error runs but gives the wrong result.