OCR GCSE Computer Science June 2025 Paper 2, Question 3(a): showing a merge sort
OCR J277/02 June 2025, Question 3(a): show how a merge sort puts 2, 7, 3, 1, 9, 6, 5, 4 into ascending order, from splitting to the final merge. The four marks explained, with a merge sort that prints every stage.
Question 3(a) of the OCR GCSE Computer Science Paper 2 sat on 20 May 2025 (J277/02) asks you to show the steps a merge sort takes on eight numbers. It is worth 4 marks: one for the splitting, and one for each level of merging.
We do not copy the exam paper here. Open it beside this page: OCR June 2025 J277/02 question paper (PDF). When you have finished, check the mark scheme too.
The question in short
The data set is 2, 7, 3, 1, 9, 6, 5, 4. Put it into ascending order with a merge sort, showing the steps.
Work it through
Step 1: split until every list has one item. You can show the halving (eight, then two fours, then four pairs, then singles) or go straight to singles.
| 2 | 7 | 3 | 1 | 9 | 6 | 5 | 4 |
|---|---|---|---|---|---|---|---|
Step 2: merge neighbours into sorted pairs.
| 2, 7 | 1, 3 | 6, 9 | 4, 5 |
|---|---|---|---|
Step 3: merge the pairs into sorted fours.
| 1, 2, 3, 7 | 4, 5, 6, 9 |
|---|---|
To merge 2, 7 with 1, 3: compare the fronts, 2 and 1, and take 1. Compare 2 and 3, take 2. Compare 7 and 3, take 3. Then 7 is left.
Step 4: merge the fours into one sorted list.
| 1, 2, 3, 4, 5, 6, 7, 9 |
|---|
There is no 8 in the data. Do not add one.
Where the four marks are
One for splitting into single items. One for the four sorted pairs. One for the two sorted fours. One for the final list, after a real attempt at the merge before it.
Where the marks are lost
- Only the final list. A sorted list with no steps gets nothing. It could have come from any algorithm.
- Merging the wrong neighbours. 3 pairs with 1, the item next to it, to make 1, 3. You cannot pick partners to make the sums easier.
- Groups of the wrong size. It must be clear that the numbers are in twos, then fours. Brackets or boxes help.
- Descending order, or different numbers. Copy the list carefully, and check which order is asked for.
- Joining first and sorting after. That is not a merge, and it is refused.
Run it
A merge sort in Python that prints the lists after every level of merging.
The program
from bugbot import *
connect()
numbers = [2, 7, 3, 1, 9, 6, 5, 4]
def merge(left, right):
result = []
while len(left) > 0 and len(right) > 0:
if left[0] <= right[0]:
result.append(left.pop(0))
else:
result.append(right.pop(0))
return result + left + right
lists = [[n] for n in numbers]
print(lists)
while len(lists) > 1:
merged = []
for i in range(0, len(lists), 2):
if i + 1 < len(lists):
merged.append(merge(lists[i], lists[i + 1]))
else:
merged.append(lists[i])
lists = merged
print(lists)
Part (c) of the same question
The steps described in part (c), comparing each value in turn from the first, are a linear search. The other thing that stops it, apart from finding the value, is reaching the end of the list. "The value is not found" on its own is refused: say how the algorithm knows.
Questions
What is the answer to OCR J277 June 2025 Paper 2 Question 3(a)?
Split into single items. Merge into pairs: 2 7, 1 3, 6 9, 4 5. Merge into fours: 1 2 3 7 and 4 5 6 9. Merge into the final list: 1 2 3 4 5 6 7 9.
What are the two stages of a merge sort?
Divide: split the list in half repeatedly until every list holds one item. Merge: combine neighbouring lists in order until one sorted list remains.
Is merge sort faster than bubble sort?
On large lists, yes, by a long way. It uses more memory, because it builds new lists as it merges.
More from this paper
- Question 1: Normal, boundary and invalid test data, and a 1 to 100 range check 9 marks
- Question 2(a), (b): Count the passes of a flowchart loop, and describe the kinds of iteration 8 marks
- Question 4: Complete an algorithm that reads numbers from a text file, and casting 6 marks
- Question 5(a), (b): A logic circuit from a description, and the truth table for A AND B 5 marks
- Question 5(d): Validate a 4 character PIN that must not be 1234 or 4321 6 marks
Every OCR J277 question we have worked · Guide: Big O notation explained
Learn it step by step
- F5.9 Merge sort and comparing algorithms Algorithms
This is our own explanation of a published exam question. It is not written or endorsed by OCR, and the question paper and mark scheme remain OCR's copyright. Read them on OCR's site with the links on this page.