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 SORT
2 repeat: one pass = go through the list from the first item to the last
3 compare each item with the one next to it
4 if the item is greater than its neighbour, swap them
5 until a pass makes no swaps
6 MERGE SORT
7 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 own
8 merge pairs of lists into new ordered lists
9 keep merging until all the lists have become one ordered list

Variables

list=7 2 9 4 6

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.

1 / 23

Step through the trace — every value is the lesson’s, not run by the page.

Step 1 of 23: 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..

Watch out: Look at the end of bubble sort: the list looks sorted before the algorithm stops. It still needs a final pass with no swaps to confirm it.

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?

Bubble sort trace

Where does this trace go wrong?

A student bubble-sorts the list 2 4 1 3 into ascending order and writes this working. One line is a mistake. Pick the first line that is wrong.

A student's answer — which line goes wrong?

Merging two sorted lists

Do the merge yourself

Merge the sorted lists A = [1, 5, 8] and B = [2, 3] into one ordered list. Fill in the gaps.

  1. Start with sorted list A = [1, 5, 8], sorted list B = [2, 3] and an empty merged list.
  2. Compare the first items of A and B: 1 and 2. Move the lower, 1, into the merged list. Merged: [1].
  3. missing step
Which line is step 3?

Which sort is better?

Is merge sort always the better choice?

The claim

Merge sort is always the better choice than bubble sort.

Place each piece of evidence to load the balance. Mark the strong ones — they count double.

  1. Merge sort will generally perform much faster than bubble sort, especially on large datasets.

    Evidence 1: does it support or challenge the claim?
  2. Bubble sort is poor at sorting large collections of unordered data.

    Evidence 2: does it support or challenge the claim?
  3. Merge sort needs more memory, because of the new lists it has to create.

    Evidence 3: does it support or challenge the claim?
  4. Merge sort is more complex to write than bubble sort, which is simpler to write.

    Evidence 4: does it support or challenge the claim?
  5. Bubble sort can be quicker than merge sort on smaller lists.

    Evidence 5: does it support or challenge the claim?
  6. Bubble sort can be quicker than merge sort on lists that are mostly in order.

    Evidence 6: does it support or challenge the claim?

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

1A bubble sort repeatedly passes through the list, comparing adjacent items and swapping them if they are in the wrong order; each complete traversal is a pass.
2Bubble sort stops after a pass with no swaps; that last pass confirms the data is in order.
3A pass over n items makes n − 1 comparisons, one for each pair of neighbours. After a pass the largest item is in its final position at the end, so later passes can skip the settled end.
4Merge sort splits the list in half until every item is in a list of its own, then merges pairs of lists into ordered lists until one ordered list remains.
5Merge sort will generally perform much faster than bubble sort, especially on large datasets, but needs more memory and is more complex to write.
6Bubble sort can be quicker on smaller or mostly ordered lists, so choosing a sort depends on the situation.

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?
One complete traversal of the list, from the first item to the last.
When two neighbouring items are compared in a bubble sort, when are they swapped?
When the current item is greater than the one next to it, so they are in the wrong order.
How does a bubble sort know it has finished?
A whole pass makes no swaps. That last pass is needed to confirm the data is in order.
After one pass of a bubble sort, what is true of the largest item?
It has reached its final position at the end of the list.
How many comparisons does one pass make over n items?
n − 1 (seven comparisons for eight cards).
Name the two ways to make a bubble sort more efficient.
Stop once no swaps were made during a pass, and reduce the number of comparisons by one after each pass.
What are the two parts of a merge sort?
Splitting, which halves the list until every item is alone, and merging, which combines pairs of lists into ordered lists until one list remains.
A merge sort has to split a list with an odd number of items. Where does the middle item go?
Into the first list. This is the convention used here; another convention would still give a valid merge sort.
How does one merge of two sorted lists work?
Compare the first items, move the lower into the merged list, repeat until one list is empty, then place the rest of the other list in order.
What does 'divide and conquer' mean?
Breaking a problem down into smaller and smaller parts until they are simple enough to solve directly.
Is merge sort always faster than bubble sort?
No. It will generally perform much faster, especially on large datasets, but it is not the most efficient choice for every case.
What are the downsides of merge sort?
It needs more memory, because of the new lists it creates, and it is more complex to write than bubble sort.
When can bubble sort be quicker than merge sort?
On smaller lists and on lists that are mostly in order.
What does the choice of sorting algorithm depend on?
Factors such as how efficient it is on large datasets, how easy it is to implement and test, how much memory it may need, and how the data is formatted.

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 posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

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.