GCSE · Computer Science · AQA · Spec 8525

Merge sort

Here's a strange way to sort: pull the list completely to pieces first, then build it back up in order. It sounds backwards, yet it usually beats bubble sort.

Merge sort · step by step

Take it apart, then put it back in order

Step through one whole merge sort of eight numbers. Watch the list fall apart into single items, then snap back together in order.

Before you press Next: how many comparisons do you think merge sort makes while it is splitting this list?

StageListsComparisons so far
Start[6 2 8 4 3 7 1 5]0

Output

 

Step 1: One unsorted list of eight numbers. Keep an eye on the right-hand column.

1 / 11

Press Next (or Play) and watch the right-hand column. It stays at 0 for longer than you might expect.

Step 1 of 11: One unsorted list of eight numbers. Keep an eye on the right-hand column..

Watch out: Splitting never puts anything in order: after the first split, 6 is still in front of 2. Every comparison happens during a merge.

Your turn

Merge two sorted lists yourself

Picture two queues, each already lined up from shortest to tallest. To combine them in order, you only ever look at the person at the front of each queue, and the shorter one goes through next. Lists work the same way. A = [3, 9, 12, 20] and B = [5, 6, 15, 22] are both already sorted. Merge them into one sorted list, and at each gap choose what happens next.

  1. Fronts: 3 v 5. Take 3. New list: [3]3 is the smaller front, so it moves across. A's new front is 9.
  2. missing step
Which line is step 2?

The price of splitting

?

Reason it through

Why isn't merge sort the best choice every time?

Link 1 of 4

First link · your turn

What does merge sort have to do before it can compare anything?

2
Locked — reveal the link above first
3
Locked — reveal the link above first
4
Locked — reveal the link above first

Make a judgement

Merge sort or bubble sort?

The claim

Merge sort is always a better choice than bubble sort.

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

  1. Merge sort is usually faster to execute than bubble sort.

    Evidence 1: does it support or challenge the claim?
  2. Merge sort is an efficient divide-and-conquer algorithm that can perform well in real-world use.

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

    Evidence 3: does it support or challenge the claim?
  4. Executing merge sort takes up extra space in memory.

    Evidence 4: does it support or challenge the claim?
  5. On smaller data sets, a simpler algorithm such as bubble sort can be faster.

    Evidence 5: does it support or challenge the claim?

Put it in writing

Explain merge sort in your own words

A list contains [7, 2, 9, 4]. (a) Explain how merge sort would sort this list into ascending order. (4 marks) (b) Give one advantage and one disadvantage of merge sort compared with bubble sort. (2 marks) [6 marks]

0 words · your answer stays on this page and is not sent anywhere.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Take the list completely apart, then build it back up in order.

What you need to know

  • Merge sort works in two phases: split, then merge.
  • Splitting keeps halving the list until every item is in a list of its own. Nothing is compared or put in order while this happens.
  • Merging combines two sorted lists by comparing their front items and taking the smaller, over and over. When one list runs out, the rest of the other goes on the end.
  • Pairs of lists keep merging until one sorted list remains.
  • Compared with bubble sort, merge sort is usually faster to execute, but it is more complex to write, uses extra memory, and can be slower on small data sets.

The big picture

Merge sort is a divide-and-conquer sorting algorithm. It splits a list until every item sits in a list of its own, then merges pairs of sorted lists, always comparing the two front items and taking the smaller, until one sorted list remains. It is usually faster to execute than bubble sort, but it is more complex to write, takes up extra memory, and on small data sets a simpler algorithm such as bubble sort can be faster.

Key points

1Split until every list holds one item: a one-item list is already sorted.
2A merge only compares the two front items, and the smaller one moves to the new list.
3All of the ordering, and every comparison, happens during the merges.
4Merge sort is an efficient divide-and-conquer algorithm that can perform well in real-world use.
5The trade-off: usually faster than bubble sort, but harder to write, hungrier for memory, and not always quicker on small data sets.

Worked example

Problem

A program needs to sort 12 readings on a small device with very little spare memory. Should it use merge sort or bubble sort? Explain the choice.

⚠ Watch out

Thinking merge sort sorts while it splits. Splitting only breaks the list up: [6 2] is still 6 then 2. All the ordering happens in the merges. The other slip: 'merging' by sticking one list onto the end of the other instead of comparing front items.

🧠

Memory hook

Smash it to singles, then zip it back up: front against front, smaller one first.

✓

Check yourself

Without scrolling up: name the two phases of merge sort, say which phase makes all the comparisons, and explain why a list with only one item in it never needs sorting.

Flashcards

(12)
What are the two phases of merge sort?
Split, then merge.
When does merge sort stop splitting?
When every item is in a list of its own.
Why is a one-item list a good place to stop splitting?
A list with one item is already sorted, so merging can start from sorted lists.
During a merge, which items get compared?
Only the front item of each list. The smaller one moves to the new list.
During a merge, one list runs out. What happens to the other list's items?
They go on the end in the order they are in. They are already sorted, so no more comparisons are needed.
In which phase are items actually put in order?
The merge phase. Splitting makes no comparisons at all.
How do you know merge sort has finished?
Only one sorted list remains.
Why is merge sort called 'divide and conquer'?
It divides the list into tiny pieces that are already sorted, then conquers by merging them back together in order.
Merge sort vs bubble sort: which is usually faster to execute?
Merge sort.
Merge sort vs bubble sort: which is more complex to write?
Merge sort.
What does executing merge sort cost besides time?
Extra space in memory.
Why can bubble sort beat merge sort on a small data set?
Merge sort has the overhead of breaking the data apart first, and on a small data set that can outweigh the time it saves.

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 8 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.