CAMBRIDGE AS & A LEVEL · SEARCH

Binary search.

Halve the remaining search range in a sorted list.

All 9618 lessons
THE VISUAL TRACE

Follow the values

00 / 06
Ready to explore

Press Play or Next step to begin. No values have been checked yet.

[
3
1
7
2
11
3
18
4
25
5
31
6
42
7
]
current checked / fixedindex starts at 1
SEARCH TARGET25
NOW IN THE ALGORITHMPress Play to begin.
01 / THE IDEA

What should you notice?

Binary search only works correctly when values are sorted. Watch how each comparison rules out half of the remaining positions.

02 / KEEP PRACTISING

Change the outcome.

Try a first value, a last value, a missing target, duplicates, negative numbers, and a single value. Use the slider to revisit any step.

Explore more 9618 lessons ↗