Tracing a linear search
A table that records the index, the element compared and the Found flag on each pass of a linear search, so you can follow it step by step.
Understanding Tracing a linear search in IGCSE Computer Science Paper 2
What it does: The IF compares the element with the target, so Found is set to TRUE only on the matching row. Every other row leaves it unchanged. This line runs once per element compared. The final value in the trace table is the number of comparisons made. Index 1 holds 4 and index 2 holds 7, so the match happens on the second pass and Found becomes TRUE. It compares 2, then 5, and then stops. That is 2 comparisons. A search that does not stop early would make all 4. A linear search checks from the start, so the first 6 at index 1 is met before the duplicate at index 3.
Common mistakes: The Found flag must start as FALSE. If it starts as TRUE, the first row of the trace table already shows TRUE and the search cannot tell when the target is missing. It should be Found ← FALSE. The comparison counter must start at 0 because no comparisons have been made yet. Starting at 1 makes the final count one too high. It should be Checks ← 0.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 296–306) and word search (Modules 296–316).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
trace tableFill in the Blanks
Spot the Error
Student with a class code? Join your class →