Merge sort is an efficient sorting algorithm that uses a divide and conquer strategy. It works by recursively splitting the list into halves until each sub-list has one element, then merging the sub-lists back together in sorted order.
Merge sort has two phases:
Sort [38, 27, 43, 3] using merge sort:
Split:
[38, 27, 43, 3] → [38, 27] and [43, 3] → [38] [27] [43] [3]
Merge:
Merge [38] and [27]: compare 38 and 27 → pick 27 → pick 38 → [27, 38]
Merge [43] and [3]: compare 43 and 3 → pick 3 → pick 43 → [3, 43]
Merge [27, 38] and [3, 43]: compare 27 and 3 → pick 3; compare 27 and 43 → pick 27; pick 38; pick 43 → [3, 27, 38, 43]
| Feature | Bubble Sort | Merge Sort |
|---|---|---|
| Worst case efficiency | O(n²) — quadratic | O(n log n) — much faster |
| Best case efficiency | O(n) if optimised | O(n log n) always |
| Extra memory needed? | No (in-place) | Yes — needs space for sub-lists |
| Practical use | Small lists only | Large datasets |
| Complexity to implement | Simple | More complex (recursive) |
8 Edexcel-style questions · instantly marked
| Term | Definition |
|---|
Timed exam-style test. No feedback until submission.