Skip to content
Menu

Year 9 (ages 13–14, Grade 8 in the US) · Computing · Algorithms · Lesson 2

Binary search

How binary search works on a sorted list, finding the middle, tracing searches, and comparing efficiency with linear search.

Exam boards: this lesson matches the AQA and Pearson Edexcel GCSE computing courses. Check which course your school follows.

Whiteboard video lesson: Binary search

22-minute video lesson

Teaching, worked examples and 20 practice questions solved step by step.

Watch free for a month

What your child will learn

  • Describe binary search
  • Trace a binary search
  • Compare with linear search
  • Explain why the list must be sorted

The method

  1. Check the list is sorted.
  2. Find the middle: (low + high) ÷ 2, rounded down.
  3. Compare; discard half.
  4. Repeat; count comparisons.

Key words: binary search, sorted, midpoint, comparison, efficiency.

Worked examples

Worked examples from the lesson, with every step.

Question 1

Use a binary search to find 16 in [2, 5, 8, 12, 16, 23, 38, 45, 56]. How many comparisons?

  1. Step 1: The list must be sorted
  2. Step 2: Check the middle

Answer: found at position 4 after 1 comparison

Question 2

Use a binary search to find 2 in [2, 5, 8, 12, 16, 23, 38, 45, 56]. How many comparisons?

  1. Step 1: The list must be sorted
  2. Step 2: Check the middle
  3. Step 3: Check the middle
  4. Step 4: Check the middle

Answer: found at position 0 after 3 comparisons

Question 3

Use a binary search to find 56 in [2, 5, 8, 12, 16, 23, 38, 45, 56]. How many comparisons?

  1. Step 1: The list must be sorted
  2. Step 2: Check the middle
  3. Step 3: Check the middle
  4. Step 4: Check the middle
  5. Step 5: Check the middle

Answer: found at position 8 after 4 comparisons