Searching: linear and binary search
How do you find one item in a list? There are two famous algorithms. One is simple; the other is much faster on big sorted lists.
Linear search
It works on any list, sorted or not.
For a list of 1,000 items it might need 1,000 checks.
Binary search
1. Look at the middle item.
2. If it is the target, stop.
3. If the target is bigger, throw away the left half. If smaller, throw away the right half.
4. Repeat with the half that is left.
Each check halves the list, so even 1,000 items need at most 10 checks.
Example
Middle item is 17. 23 is bigger, so keep 23, 31, 40.
Middle is 31. 23 is smaller, so keep 23.
Check 23: found after 3 checks. A linear search needs 5 checks.
Use binary search to find 9 in 2, 5, 9, 14, 18, 21, 27, 33, 38, 41, 50. Which items are checked?
- 11 items: the middle one is 21. 9 is smaller, keep the left half: 2, 5, 9, 14, 18.
- Middle is 9: found.
Answer: 21, 9
Linear search checks every item in order and works on any list. Binary search needs a sorted list; it checks the middle and halves the list each time, so it is far faster on large lists.
- AND
- A Boolean operator that gives True (1) only when both inputs are True.
- Binary
- A number system that uses only two digits, 0 and 1. Computers store all data in binary.
- Binary search
- A search that checks the middle item of a sorted list, then throws away the half that cannot hold the target, again and again.
- List
- A data structure that stores many items under one name, in order, such as scores = [4, 7, 2].
- Linear search
- A search that checks each item in a list in turn, from the start, until the target is found or the list ends.
- NOT
- A Boolean operator that flips its input: True becomes False and False becomes True.
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
A linear search looks for 17 in the list 3, 8, 12, 17, 23, 31, 40. How many items does it check?
Show the answer
Answer: 4
It checks 3, 8, 12, 17: 4 items.
Which list can binary search be used on?
- [9, 3, 7, 1]
- [2, 5, 8, 13, 21]
- [5, 2, 8, 1, 9]
- [10, 30, 20]
Show the answer
Answer: [2, 5, 8, 13, 21]
Binary search needs the list to be in order.
Check you have got it
Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.
Facts checked against the sources below, 27 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.