66 exam-style questions plus unlimited generated ones on this topic, at up to four difficulty levels, with full mark schemes. Notes and past-paper booklets are open to everyone. Practice needs a free account.
Or take a quick quiz: 11 questions on this subtopic in GCSE Computer Science (OCR), marked as you tap.
A merge sort splits a list in half again and again until each part holds one item, then merges the parts back together in order. You need to show the splitting and merging stages on a given list, describe how two lists are merged, and compare merge sort with bubble and insertion sort.
Key facts
Divide: split the list in half repeatedly until every list has 1 item
A list of one item is already sorted
Merge: compare the front items of two lists and move the smaller one
When one list runs out, copy the rest of the other list across
Keep merging pairs of lists until one sorted list is left
Pro: fast and efficient on large lists
Con: extra memory, harder to code, no quicker on small or already sorted lists
Notes
How a merge sort works
Divide: split the list in half, then split each half in half, and keep going until every sub-list has one item. A list of one item is already sorted.
Merge: merge pairs of sub-lists into sorted lists of two, then fours, and so on, until there is one sorted list.
If a list has an odd number of items, one half gets one more item than the other. Follow any rule the question gives about which side.
To recognise it in code: the list is split at a middle position into a left half and a right half, then a loop compares the front items of two lists and adds the smaller to a new list.
How two sorted lists are merged
Compare the first item of each list. Move the smaller one into the new list.
Compare the new front items and repeat.
When one list is empty, copy the rest of the other list across in order (it is already sorted).
Merge sort: split down to single items (top half), then merge back in order (bottom half)
Advantages and disadvantages
Advantage: much more efficient (quicker) than bubble sort or insertion sort for large lists, because it makes far fewer comparisons.
Advantage: it takes a similar time whatever the starting order of the list.
Disadvantages: it needs extra memory to hold the sub-lists; it is more complex to code; it still does every split and merge even if the list is already sorted, and for small lists it can be slower than the simpler sorts.
How to answer each type of question
Show the stages of a merge sort
3 to 4 marksGrade 6
Split the list into halves, then quarters, down to single items. Show each level.
Merge neighbouring single items into sorted pairs.
Merge the pairs into sorted fours, and so on.
Keep each list in square brackets so the examiner can see the groups.
Example. Show how a merge sort would put these names into alphabetical order: Tom, Ann, Raj, Eve, Kim, Bo, Zac, Liv. [4]
Show the model answerHide the model answer
Split: [Tom, Ann, Raj, Eve] [Kim, Bo, Zac, Liv], then [Tom, Ann] [Raj, Eve] [Kim, Bo] [Zac, Liv], then single items
(1).
Merge: [Ann, Tom] [Eve, Raj] [Bo, Kim] [Liv, Zac]
(1).
[Ann, Eve, Raj, Tom] [Bo, Kim, Liv, Zac]
(1).
[Ann, Bo, Eve, Kim, Liv, Raj, Tom, Zac]
(1).
Describe how two lists are merged
2 to 3 marksGrade 5
Compare the first item in each list.
Move the smaller into the new list and repeat with the next front items.
When one list is empty, add the rest of the other list.
Example. During a merge sort, the lists [4, 10, 15] and [3, 11, 12, 20] are merged. Describe how they are merged and give the merged list. [3]
Show the model answerHide the model answer
Compare the first item of each list and move the smaller one into the new list (1). Repeat with the front items until one list is empty, then add the remaining items of the other list (1). Merged list: 3, 4, 10, 11, 12, 15, 20 (1).
Evaluate merge sort for a scenario
2 to 4 marksGrade 7
Link the size of the data to efficiency: merge sort suits large lists.
Give the reason: far fewer comparisons than bubble or insertion sort.
If asked for a drawback, mention extra memory or complexity.
Example. An online shop sorts 2 million product prices every night. Explain why a merge sort is a suitable choice, and give one drawback. [3]
Show the model answerHide the model answer
Merge sort is much quicker (more efficient) than a bubble sort or an insertion sort on a large list (1) because it needs far fewer comparisons
(1).
Drawback: it needs extra memory to store the sub-lists / it is more complex to program
(1).
Don’t lose marks
Merging before the list has been split all the way down to single items.
Sorting a whole group in one step instead of merging two groups.
Losing or duplicating an item: count the items at every stage.
Saying merge sort uses less memory than bubble sort: it uses more.
Describing a merge as 'join the lists together' without comparing the front items.
More tips
Memory tricks
Merge sort in two words: split, then merge.
Sense check: at every merging level, each group must be in order and the total number of items must not change.
Merging is like two queues of people sorted by height: you always take the shorter of the two people at the front.
Exam technique
Show every level of splitting and merging on its own line; each level is usually a mark.
Use brackets to show where each sub-list starts and ends.
In 'which sort' questions, mention the size of the data and memory, and link them to the scenario.
What each grade needs
What you need to be able to do, from the first marks up to the top grade.
Grade 4
Describe the splitting stage of merge sortThe list is repeatedly divided in half until every sub-list contains one item.
Grade 5
Merge two sorted lists into oneCompare the front item of each list and move the smaller one across, repeatedly.
Grade 6
Show every stage of a merge sortShow all the splits down to single items, then each round of merging.
Grade 7
Give advantages and disadvantages of merge sortMuch faster on large lists, but uses more memory and is harder to code.
Grade 8
Choose a suitable sort for a scenarioJustify merge sort for large data sets, or another sort when memory or simplicity matters.
Quick recall
Cover the answers and test yourself. The app has these as flashcards that come back just before you'd forget them.
During a merge sort, the sorted lists [2, 8] and [5, 9] are merged into one list. State the merged list.
2, 5, 8, 9
Complete the sentences about the second stage of a merge sort. Use words from this list: deleted, merged, reversed, sorted, split. In the second stage, pairs of sub-lists are ____________ together. Each new list that is made is ____________.
merged; sorted
A merge sort can put a list of numbers in order. State one type of data, other than numbers, that a merge sort can also put in order.
Names (strings)
Name the process of combining two sorted lists into one sorted list.
Merging
Is this statement about a merge sort true or false? If it is false, correct it. “A merge sort always splits a list into two halves with exactly the same number of items.”
False. A list with an odd number of items cannot be split into two equal halves.
Sample questions
Written for this site in the style of OCR exam questions. They are not taken from real past papers.
Question 1Easy4 marks
(a) Describe the first stage of a merge sort.
[2]
(b) Which statement about merge sort is true? Tick (✓) one box.
[1]
It only works on lists that are already sorted
It is usually more efficient than a bubble sort for large lists
It compares each item with the item next to it and swaps them
It can only sort numbers, not words
(c) Give one disadvantage of a merge sort compared with a bubble sort.
[1]
Show the answer and mark scheme
(a)
the list is repeatedly divided / split in half
until each sub-list contains only one item
(b)Answer: It is usually more efficient than a bubble sort for large lists
(c)
uses more memory (to store the sub-lists)
more complex to code / understand
carries out all the splitting and merging even if the list is already sorted
can be slower for very small lists
Question 2Medium5 marks
A merge sort is used to sort a list of toys into alphabetical order. The list has already been split into single items: