Searching and sorting
Finding and ordering data quickly matters for every app you use. You need to know two searches and two sorts.
Linear and binary search
Binary search: the list must be sorted. Check the middle item; if it is not the target, throw away the half that cannot contain it. Repeat. Much faster on big lists.
Bubble sort
One full pass moves the largest item to the end. Repeat passes until no swaps are needed.
[5, 1, 4, 2, 8] after one pass becomes [1, 4, 2, 5, 8].
Merge sort
Then merge pairs of lists back together in order.
Merge sort is usually much faster than bubble sort on large lists, but uses more memory.
Use binary search to find 23 in [3, 8, 12, 15, 23, 31, 40].
- Middle item is 15. 23 > 15, so discard the left half.
- Remaining: [23, 31, 40]. Middle item is 31. 23 < 31, so discard the right.
- Remaining: [23]. Found.
Answer: Found in 3 comparisons.
Linear search checks every item; binary search halves a sorted list each time. Bubble sort swaps neighbours in passes; merge sort splits then merges and is faster on big lists.
- Linear search
- Checks each item in turn from the start of a list until the target is found or the list ends.
- Binary
- Base 2: the number system that uses only the digits 0 and 1.
- Binary search
- Repeatedly checks the middle item of a sorted list and discards half the list.
- Bubble sort
- Sorts by comparing neighbouring items and swapping them, in passes, until a pass makes no swaps.
- Merge sort
- Splits a list into single items, then merges pairs of lists back together in order.
All GCSE and International GCSE Computer Science key terms and definitions →
- Not “It uses less memory”. Merge sort usually uses more memory, not less.
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.
The list [9, 2, 7, 4, 1] needs searching. Why can binary search not be used on it?
- It has an odd number of items
- It contains numbers
- It is too short
- It is not sorted
Show the answer
Answer: It is not sorted
Binary search needs sorted data.
Show [5, 1, 4, 2] after ONE pass of bubble sort. Type it like 1, 2, 3, 4.
Show the answer
Answer: 1, 4, 2, 5
5,1: swap; 5,4: swap; 5,2: swap. Result: 1, 4, 2, 5.
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.
- Pearson Edexcel GCSE Computer Science (1CP2) specification, topic 1.2.6
- Pearson Edexcel International GCSE Computer Science (4CP0) specification, topic 1.1.8
Facts checked against the sources below, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.
What do exam command words like explain and evaluate mean? →