Bubble sort trace table questions appear on every GCSE Computer Science exam paper. The marks are almost always awarded for showing every comparison in every pass — not just the swaps. This guide shows you exactly what to write.
🛠️ Open Algorithm Visualiser →This is the level of detail expected in the exam. Show every comparison, not just swaps.
| Comparison | Swap? | List after |
|---|---|---|
| 5 vs 3 | YES | [3, 5, 8, 1, 4] |
| 5 vs 8 | no | [3, 5, 8, 1, 4] |
| 8 vs 1 | YES | [3, 5, 1, 8, 4] |
| 8 vs 4 | YES | [3, 5, 1, 4, 8] |
| Comparison | Swap? | List after |
|---|---|---|
| 3 vs 5 | no | [3, 5, 1, 4, 8] |
| 5 vs 1 | YES | [3, 1, 5, 4, 8] |
| 5 vs 4 | YES | [3, 1, 4, 5, 8] |
| Comparison | Swap? | List after |
|---|---|---|
| 3 vs 1 | YES | [1, 3, 4, 5, 8] |
| 3 vs 4 | no | [1, 3, 4, 5, 8] |
| Comparison | Swap? | List after |
|---|---|---|
| 1 vs 3 | no | [1, 3, 4, 5, 8] |
Try these before expanding the hints. Write your answer, then compare.
Trace bubble sort on the list [6, 3, 8, 2, 5]. Show the state of the list after each complete pass.
Mark scheme hint: Pass 1: [3,6,2,5,8]. Pass 2: [3,2,5,6,8]. Pass 3: [2,3,5,6,8]. Pass 4: no swaps → stop. 1 mark per correct pass state. Full marks requires showing correct early termination on pass 4.
Describe how bubble sort works. Your answer should include a description of how the algorithm knows when to stop.
Mark scheme hint: Adjacent pairs compared and swapped if in wrong order [1]; largest unsorted value moves to correct position each pass [1]; passes repeated until no swaps occur in a complete pass [1]; this indicates the list is sorted and the algorithm terminates [1].
A list has 8 elements. What is the maximum number of passes bubble sort will need?
Mark scheme hint: n-1 = 7 passes [1]. In the worst case (fully reverse sorted), n-1 passes are needed. Note: with early termination, often fewer passes are needed in practice.
State one advantage of bubble sort over merge sort and one disadvantage.
Mark scheme hint: Advantage: simpler to understand and code / uses less memory (in-place) / can terminate early for nearly-sorted lists [1]. Disadvantage: much less efficient for large lists — performs many more comparisons and swaps than merge sort [1].
Hundreds more exam-style questions with full mark schemes — all free.
Question Bank →Only writing out rows where a swap happens and skipping no-swap comparisons.
Write EVERY comparison. The mark scheme specifically includes no-swap comparisons. "5 vs 3: 5 > 3, SWAP" AND "3 vs 8: 3 < 8, no swap" both earn marks.
Stopping after the list looks sorted without checking for early termination — or not mentioning early termination at all.
Do an extra pass. If it produces no swaps, write "Pass X: no swaps — list is sorted, algorithm terminates." This is worth a dedicated mark.
"Bubble sort compares every element with every other element"
"Each pass compares adjacent pairs from left to right. After each pass, the upper limit reduces by 1 as the rightmost elements are in their final positions."
One-to-one online tutoring with an experienced Computer Science teacher. Work through exactly the topics you find hardest — exam technique, algorithms, programming and more.
In the worst case (reverse-sorted list), bubble sort needs n-1 passes for a list of n items. Each pass places one more element in its final position. With early termination (stopping if a pass makes no swaps), a nearly-sorted list might finish in just one or two passes.
If a complete pass through the list produces no swaps, the list must already be sorted — so the algorithm can stop immediately. In the exam, always mention this: "if no swaps occur in a pass, the algorithm terminates early." This is worth 1 mark in description questions.
Yes — this is where students lose marks. The mark scheme awards marks for each comparison, not just for swaps. If you only write out the swaps and skip the no-swap comparisons, you will lose marks. Write every comparison on every pass.
After pass 1, the largest element is in its final position at the right end. After pass 2, the two largest are in position. Generally, after pass k, the k largest elements are correctly placed at the right. This is why each pass can be one element shorter than the previous one.