AQA A LEVEL · SEARCH

Binary search.

Halve the remaining search range in a sorted list.

All 7517 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
0
7
1
11
2
18
3
25
4
31
5
42
6
]
current checked / fixedindex starts at 0
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 7517 lessons ↗