GCSE · Computer Science · AQA · Spec 8525
Compare bubble sort and merge sort
One list, two sorting methods. One keeps swapping neighbours; the other chops the list into single cards, then rebuilds it in order. Which wins? It depends, and that's the point.
Computer Science · Sorting algorithms
One list, two very different sorts
Bubble sort works along the list again and again. Merge sort chops it up first. Step through both on the same five cards.
Step through bubble sort first, then merge sort. Which one is doing more comparing as it goes?
1 BUBBLE SORT2 repeat: one pass = go through the list from the first item to the last3 compare each item with the one next to it4 if the item is greater than its neighbour, swap them5 until a pass makes no swaps6 MERGE SORT7 split the list in half (odd length: the first list gets the middle item), and keep splitting until every item is in a list of its own8 merge pairs of lists into new ordered lists9 keep merging until all the lists have become one ordered list
Variables
Output
Step 1: Here are five cards: 7 2 9 4 6. Bubble sort's plan is simple: look at two neighbours, swap them if they are the wrong way round, shuffle along, repeat. Press Next and predict each swap before you see it.
Step through the trace — every value is the lesson’s, not run by the page.
Predict, then check
Eight cards are being bubble-sorted. Commit to an answer before you look.
The first pass over eight cards compares neighbours from the first card to the last. How many comparisons is that, and how many does the second pass need if it skips the pair that is already settled?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Two ways to sort the same list, and why neither is best every time.
What you need to know
- Bubble sort compares neighbouring items and swaps them whenever they are in the wrong order.
- One pass is a complete trip through the list: compare each item with the next, and swap if the current one is greater.
Have a goYour friend Sam says: 'A pass is one swap, so if a list needs five swaps, that's five passes.' Is Sam right?
No. A pass is one complete trip through the list, however many swaps happen during it.
A pass is counted by trips through the list, not by swaps, so one pass can make several swaps.
- Keep making passes until one makes no swaps. That last pass is needed to confirm the data is in order.
- After a pass the largest item is at the end, and a pass over n items makes n − 1 comparisons.
Have a goA pass has just finished on the list 6 3 8 5. Without tracing it, which item must now be in the last place?
8, the largest item.
After a single pass the largest item has reached its final position at the end; the other items may still be out of order.
- You can make bubble sort more efficient: stop once a pass makes no swaps, and make one fewer comparison after each pass.
- Merge sort has two parts: splitting the list in half until every item is alone, then merging pairs of lists into ordered lists.
- To merge, keep moving the lower of the two first items across. When one list is empty, add the rest of the other.
Have a goTwo sorted lists, [2, 9] and [4, 6], are being merged. Which item moves into the merged list first?
2, because it is the lower of the two first items (2 and 4).
A merge compares only the first items of the two lists and moves the lower one, not the last items or the higher one.
- Merge sort is a divide and conquer algorithm, and it generally runs much faster than bubble sort, especially on large datasets.
- The price: merge sort needs more memory for its new lists and is more complex to write, while bubble sort is simpler.
- Bubble sort can be quicker on smaller or mostly ordered lists, so the best choice depends on factors such as size, memory and ease of testing.
The big picture
Bubble sort works along the list comparing neighbours and swapping them, pass after pass, until a pass makes no swaps. Merge sort splits the list down to single items and then merges pairs of lists back into one ordered list. Merge sort will generally perform much faster on large datasets, but it needs more memory and is more complex to write, so the best choice depends on the situation.
Key points
Worked example
Problem
Use a bubble sort to put the list 9 5 8 3 into ascending order. Write the list at the end of each pass, and say how many passes are needed.
⚠ Watch out
Stopping a bubble sort as soon as the list looks sorted (it needs one more pass with no swaps), or assuming merge sort is always best (it is generally faster on large datasets, but needs more memory and is harder to write).
Memory hook
Bubble: neighbours swap, and the biggest item floats to the end. Merge: chop it all the way down, then build it back up in order.
Check yourself
Cover the page and explain to a friend how both sorts handle the same five cards: what does bubble sort do first, and what does merge sort do before comparing anything?
Flashcards
(14)What is a pass in a bubble sort?
When two neighbouring items are compared in a bubble sort, when are they swapped?
How does a bubble sort know it has finished?
After one pass of a bubble sort, what is true of the largest item?
How many comparisons does one pass make over n items?
Name the two ways to make a bubble sort more efficient.
What are the two parts of a merge sort?
A merge sort has to split a list with an odd number of items. Where does the middle item go?
How does one merge of two sorted lists work?
What does 'divide and conquer' mean?
Is merge sort always faster than bubble sort?
What are the downsides of merge sort?
When can bubble sort be quicker than merge sort?
What does the choice of sorting algorithm depend on?
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 24 November 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.