Linear search
Linear search: check every item from the start until you find it.
- Works on any list, sorted or not.
- Simple.
- Slow on long lists: a million items may need a million checks.
Topic 12 Searching and sorting
KS3 Computing · Searching finds an item. Sorting puts items in order. Some algorithms are hugely faster than others on big lists, and the difference grows as the list grows.
Computational ThinkingCambridge Lower Secondary Computing 0860
Say each word, then read what it means. Every one is in the glossary too.
Read it here, or open the study page below to go one step at a time with things to try.
Linear search: check every item from the start until you find it.
Binary search needs a sorted list. Like a dictionary: open in the middle, throw away the wrong half, repeat.
| Items | Linear (worst) | Binary (worst) |
|---|---|---|
| 10 | 10 | 4 |
| 1,000 | 1,000 | 10 |
| 1,000,000 | 1,000,000 | 20 |
Why so fast? Each check halves the list. Doubling the list only adds one check. (2¹⁰ = 1,024 and 2²⁰ ≈ 1 million.)
Open the study page and go one step at a time.
One question at a time. The reason shows after each answer.