Tracing a binary search
Each row of a binary search trace table updates low, high and mid. The range halves each step until the target is found or low becomes greater than high.
Understanding Tracing a binary search in WA Computer Science ATAR Unit 1
What it does: The middle value is too small, so every item at or below mid is ruled out. Low moves to mid + 1, which gives a new row in the trace table. 8 DIV 2 = 4, so the first row of the trace table has mid = 4 and list[4] = 15. 21 is greater than 15, so the target must be in the upper half. Low moves up to mid + 1 = 5 and the range shrinks. 12 DIV 2 = 6. list[6] = 27, which is greater than 21, so high becomes 5 on the next row.
Common mistakes: Pseudocode lists start at index 1, so the first row of the trace table must have low ← 1. Starting at 0 gives the wrong first mid (4 instead of 5). The middle index is found by adding low and high, then using DIV 2. Subtracting gives a negative number, not the middle. It should be mid ← (low + high) DIV 2.
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 100–314) and word search (Modules 100–470).
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
mid ← (low + high) DIV 2Fill in the Blanks
Spot the Error
Student with a class code? Join your class →