GCSE · Computer Science · AQA · Spec 8525
Compare linear and binary search
You don't find a word in a dictionary by reading from 'aardvark'. You open it near the middle and jump, which only works because it's in order.
Computer Science · Searching
Two ways to find 38
One sorted list, searched twice. Keep an eye on the comparisons count and the output at the bottom.
Before you press Next: which search will find 38 in fewer comparisons, and roughly how many fewer?
1 LINEAR: check each item in turn2 not 38 → move to the next item3 38 → found, stop4 BINARY: compare with the mid-point5 38 → found, stop6 38 > mid → keep the right half7 38 < mid → keep the left half
Variables
Output
Step 1: Here's our list, already in order, smallest first. Both searches will hunt for the same number: 38. Linear search goes first, and it starts at the very front.
Step with Next, or press Play. The · marks are items binary search has thrown away.
Predict, then check
Same seven numbers as before, but jumbled.
The list is now 31 4 47 22 9 38 15, not in order. A binary search looks for 9, which is definitely in the list. What happens?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
One checks every item in turn. The other throws away half the list with each comparison, but only if the list is in order.
What you need to know
- A linear search checks each item in a list one at a time, starting from the first.
- A linear search works on data in any order, and on lots of types of data, including strings.
- Linear search best case: the item is the very first one. Worst case: it is the last one, or not in the list at all, so every item is checked.
- A binary search compares the search item with a mid-point, discards half of the remaining data with each comparison, and repeats until the item is found.
- A binary search can only be used on an ordered list. With unordered data, use a linear search or sort the data first.
- On average, a binary search finds an item in less time than a linear search.
The big picture
A linear search checks each item in a list one at a time, so it works on data in any order, including strings. A binary search compares the item with a mid-point and discards half of the remaining data with each comparison. That makes it quicker on average, but it can only be used on an ordered list.
Key points
Worked example
Problem
A list holds these names, in this order: Priya, Tom, Aisha, Leo, Maya. Choose a suitable search to find Leo, trace it, and give the best and worst case for this list.
⚠ Watch out
Forgetting that 'not in the list at all' is a worst case for linear search too. The search can't stop early: it has to check every item before it can say the item isn't there.
Memory hook
Linear walks the line. Binary chops it in half, but only if the line is in order.
Check yourself
Without looking back, explain in two sentences why binary search can throw away half the list after one comparison, and what would stop that from working.
Flashcards
(11)What does a linear search do?
Does a linear search need the data to be in order?
What types of data can a linear search be used on?
When does a linear search make its fewest comparisons, and when its most?
What does a binary search do?
What must be true of a list before you use binary search?
Why does binary search need ordered data?
Your data is unordered. What are your two options?
List in order, smallest first. The search item is bigger than the mid-point. What gets discarded?
Which search is quicker on average, and why?
Is binary search quicker on every single search?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore AQA GCSE Computer Science topics
How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 30 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.