What Is a Merge Sort?
A merge sort divides a list into single items, then merges the lists back together in order.
Interactive Demo
Watch a Merge Sort
Being comparedMoved to the new listLists being mergedOne list
Stage –
Lists 1
Comparisons 0
The steps
- Divide: keep splitting the lists in half until every list has one item
- Merge: compare the first item in two lists. The smaller goes into a new list. Repeat until both lists are used up
- Keep merging pairs of lists until there is one sorted list
If a list has an odd number of items, the first list gets the extra item, e.g. [5, 1, 4] → [5, 1] and [4]. A list with no partner to merge with is carried down unchanged.
Pre-requisite: the items must be able to be compared and put in order. The list does not need to be sorted already.
Try It
Interactive Practice
Merge Two Lists
Both lists are already sorted. Click the first item that should go into the new list next.
Right first time 0 / 0
Interactive Practice
Stage by Stage
Type the lists after each stage, with each list in square brackets.
Stages right 0 / 0
Sample Questions
Write your answer, then reveal the mark scheme and tick each point you included.
Interactive Practice
Write & Mark
Interactive Practice
Complete the Explanation
Choose the right word for each gap.
Merge Sort Challenges
Complete
0
Points
0
Challenge