Cambridge O Level Computer Science · Syllabus 2210 · Algorithm Design and Problem-Solving
Bubble Sort
What is Bubble Sort?
A standard method of solution that puts a collection into order by repeatedly comparing pairs of adjacent items and swapping them when they are in the wrong order; each complete journey through the collection is a pass, after which the largest remaining value has reached its final position, and passes continue until one pass makes no swaps.
This definition is part of the Algorithm Design and Problem-Solving chapter in Cambridge O Level Computer Science.
Bubble Sort in context
Topic 7 is about the work that happens before and around writing code. You analyse a problem (identify it, strip away what does not matter, break it into parts, and name the inputs, processes, outputs and storage), you design a solution (structure diagram, flowchart, pseudocode), you code it, and you test it with data you chose on purpose. Along the way you use a small fixed set of standard methods — linear search, bubble sort, totalling, counting, maximum, minimum, average — you protect the input with validation and verification, and you prove behaviour with trace tables and with normal, abnormal, extreme and boundary test data. Nothing in this topic requires you to be fluent in a programming language; it requires you to be exact.
The syllabus limits the standard methods of solution to seven: linear search, bubble sort, totalling, counting, and finding the maximum, minimum and average values. Five of them are “accumulator” methods — a variable is set up before a loop, updated inside it, and used after it. Every one of them has the same three parts, and in every one of them the marks are lost in the same place: the value the accumulator starts with, and whether the update happens on every item or only on some.
A bubble sort arranges a collection into order by repeatedly comparing adjacent items and swapping them when they are in the wrong order. One journey through the collection is a pass. After each pass the largest remaining value has moved to its correct place at the end, so passes are repeated until a complete pass makes no swaps, at which point the collection is sorted.
Common mistakes with Bubble Sort
- M12. “A bubble sort compares any two values.” Correct It compares only adjacent values — Values[Index] with Values[Index + 1] — and swaps them when they are in the wrong order.
Questions students ask about Bubble Sort
If a bubble sort finishes sorting the data on pass 2, why does it do a pass 3?
Because the algorithm has no way of knowing the data is sorted except by making a complete pass with no swaps. Pass 3 makes the comparisons, finds nothing to swap, leaves the flag TRUE, and the loop ends. In an exam answer, showing that final quiet pass is part of showing that you understand the stopping rule.

