Worst-case comparisons: linear versus binary search
Worst-case comparisons for binary search: it halves a sorted range, so 1000 items need about 10 steps. Linear search needs up to n, so 1000 items could need 1000 comparisons.
Understanding Worst-case comparisons: linear versus binary search in WA Computer Science ATAR Unit 1
What it does: Finding the middle and discarding half the range after each comparison is what gives binary search about log2 n steps. Linear search checks items one by one, so in the worst case it checks all n items. For n = 1000 that is 1000 comparisons. Worst case means the least lucky situation, such as the target being last or missing. Finding it first is the best case.
Common mistakes: Binary search halves the range again and again, so its worst case is about log2(n) comparisons (about 10 for 1000 items), not n / 2. The line should output log2(n). The step counter must start at 0 before counting how many times the range can be halved. Starting it at range (1000) would give a wrong answer. It should be steps ← 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 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
log2 nFill in the Blanks
Spot the Error
Student with a class code? Join your class →