📁 Paper 1 · 3.1 Fundamentals of Algorithms
3.1.4b Sorting Algorithms — Merge Sort
AQA 8525 · GCSE Computer Science · ~14 min read
Notes
──
Video
──
Slides
──
Worksheet
──
Quiz

What is Merge Sort?

Merge sort is a sorting algorithm that uses a divide and conquer strategy. It works by:

  1. Splitting the list repeatedly in half until every sub-list has just one element
  2. Merging pairs of sub-lists back together in sorted order until the whole list is reunited

A list of one element is already sorted — so the magic is all in the merge step.

Worked Example — Sort [8, 3, 5, 1, 6, 2]

Phase 1 — Split

Original:
8
3
5
1
6
2
↓ split
Split 1:
8
3
5
1
6
2
↓ split again
Split 2:
8
3
5
1
6
2
↓ split again
Split 3:
8
3
5
1
6
2

Every element is now alone — each is a sorted list of 1.

Phase 2 — Merge (in sorted order)

Merge 1:
3
8
5
1
2
6
↑ merge pairs sorted
Merge 2:
3
5
8
1
2
6
↑ merge halves sorted
Final:
1
2
3
5
6
8

How the Merge Step Works

When merging two sorted sub-lists, compare the first element of each and take the smaller one. Repeat until all elements are placed.

Example: Merge [3, 5, 8] and [1, 2, 6]:

  1. Compare 3 vs 1 → take 1 → result: [1]
  2. Compare 3 vs 2 → take 2 → result: [1, 2]
  3. Compare 3 vs 6 → take 3 → result: [1, 2, 3]
  4. Compare 5 vs 6 → take 5 → result: [1, 2, 3, 5]
  5. Compare 8 vs 6 → take 6 → result: [1, 2, 3, 5, 6]
  6. Remaining: take 8 → result: [1, 2, 3, 5, 6, 8] ✓

AQA Pseudo-code

// Split phase — keep splitting until 1 element SUBROUTINE mergeSort(list) IF LEN(list) ≤ 1 THEN RETURN list // base case: 1 element is already sorted ENDIF mid ← LEN(list) DIV 2 left ← mergeSort(list[0:mid]) // recursively sort left half right ← mergeSort(list[mid:LEN(list)]) // recursively sort right half RETURN merge(left, right) ENDSUBROUTINE // Merge phase — combine two sorted lists SUBROUTINE merge(left, right) result ← [] WHILE LEN(left) > 0 AND LEN(right) > 0 IF left[0] ≤ right[0] THEN APPEND left[0] TO result REMOVE left[0] FROM left ELSE APPEND right[0] TO result REMOVE right[0] FROM right ENDIF ENDWHILE RETURN result + left + right // append any remaining elements ENDSUBROUTINE

Efficiency of Merge Sort

PropertyDetail
Time complexityO(n log n) — far better than bubble sort's O(n²)
n = 1,000 items~10,000 comparisons (vs ~1,000,000 for bubble sort)
n = 1,000,000 items~20,000,000 comparisons (vs ~1 trillion for bubble sort)
Space complexityNeeds additional memory for the sub-lists during merging

Bubble Sort vs Merge Sort

FeatureBubble SortMerge Sort
Time complexityO(n²)O(n log n)
For n = 1,000~1,000,000~10,000
MemoryIn-place (minimal)Uses extra memory
SimplicitySimpler codeMore complex
Best forSmall/nearly sorted listsLarge lists where speed matters
Exam tip: The two phases of merge sort are split (divide) and merge (conquer). Always describe both phases in your answer. The key advantage over bubble sort is that merge sort is O(n log n) — state this explicitly.
⚠️ Common Mistakes
  • Only describing the split phase — you must also describe how sorted sub-lists are merged back together
  • Confusing merge sort with binary search — they both "halve" but serve completely different purposes
  • Forgetting that merge sort uses more memory — it requires additional space for the sub-lists
  • Not stating O(n log n) when comparing to bubble sort — this is the key exam point
Video coming soon
This lesson video is in production

Key points covered in this video

  • Divide and conquer — the two phases explained
  • Visual trace: splitting [8, 3, 5, 1, 6, 2] down to single elements
  • Merging sorted sub-lists step by step
  • Why merge sort is O(n log n) and bubble sort is O(n²)
  • Trade-off: speed vs memory usage
Click slide or press arrow keys to navigate
✍️

Exam-style Worksheet — 3.1.4b Merge Sort

8 AQA-style questions · 24 marks · Mark schemes revealed on submit

Q1Describe the two phases of merge sort.[4 marks]
✅ Mark scheme
Mark scheme
Split phase: the list is repeatedly divided in half [1] until all sub-lists have just one element [1]; Merge phase: pairs of sub-lists are merged together [1], comparing elements from each sub-list and placing the smaller one first, until all lists are reunited in sorted order [1].
Q2Show the split phase for the list [5, 2, 8, 1, 9]. Draw the tree of sub-lists after each split.[3 marks]
✅ Mark scheme
Mark scheme
[5,2,8,1,9] → [5,2] and [8,1,9] [1]; → [5],[2] and [8],[1,9] → [8],[1],[9] [1]; 5 single-element sub-lists: [5],[2],[8],[1],[9] [1].
Q3Merge [2, 5] and [1, 8] into one sorted list. Show each comparison.[3 marks]
✅ Mark scheme
Mark scheme
Compare 2 vs 1 → take 1 [1]; compare 2 vs 8 → take 2; compare 5 vs 8 → take 5 [1]; take remaining 8 → result: [1,2,5,8] [1].
Q4State the time complexity of merge sort and explain what it means.[2 marks]
✅ Mark scheme
Mark scheme
O(n log n) [1]; this means the number of operations grows proportionally to n multiplied by log₂(n) — much more efficient than O(n²) for large datasets [1].
Q5For a list of 1,000 items: estimate comparisons for (a) merge sort and (b) bubble sort. Which is more efficient?[3 marks]
✅ Mark scheme
Mark scheme
(a) Merge sort: ~10,000 comparisons (1,000 × log₂1,000 ≈ 1,000 × 10) [1]; (b) Bubble sort: ~1,000,000 comparisons (1,000²) [1]; merge sort is more efficient for large lists [1].
Q6Give one disadvantage of merge sort compared to bubble sort.[2 marks]
✅ Mark scheme
Mark scheme
Merge sort requires additional memory/space to store the sub-lists during the merging process [1]; it is also more complex to implement than bubble sort [1]. Award 2 for a well-explained single disadvantage.
Q7A programmer needs to sort a list of 10,000,000 items quickly. Explain which sorting algorithm they should use and why.[3 marks]
✅ Mark scheme
Mark scheme
Merge sort [1]; it is O(n log n) which is far more efficient than bubble sort's O(n²) for large lists [1]; for 10,000,000 items: merge sort ~230,000,000 comparisons vs bubble sort ~100,000,000,000,000 [1].
Q8What is a 'base case' in the merge sort algorithm, and why is it needed?[4 marks]
✅ Mark scheme
Mark scheme
The base case is when a sub-list has just one element [1]; a list of one element is trivially sorted [1]; it stops the recursive splitting from continuing indefinitely [1]; without a base case, the algorithm would recurse forever causing a stack overflow [1].
Compare your answers to the mark schemes above.
Topic Quiz
Question 1 of 15
You scored
out of 15
Card 1 of 6
Click to flip
🎉
All cards reviewed!
TermDefinition
🎯

Mini Test — 3.1.4b Merge Sort

Timed exam conditions. No feedback until you submit.

  • 8 questions · 8 marks · 10 minutes
  • 5 multiple choice + 3 short answer
  • Mark schemes revealed after submission
← 3.1.4a Bubble Sort
8 of 57 · AQA 8525
3.2.1 Data Types →