How do computers put a list of values into order?
Understand and explain how the bubble sort and merge sort algorithms work, trace each one, and compare them in terms of method and efficiency.
A focused answer to AQA GCSE Computer Science 3.1.4, covering how bubble sort and merge sort work, how to trace each one, and how they compare in method and efficiency.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
AQA wants you to explain how bubble sort and merge sort work, trace each one on a list of values, and compare them in terms of how they work and how efficient they are.
Bubble sort
It is simple to write and sorts in place (no extra lists needed) but is slow, because for a list of items it may need close to comparisons in the worst case.
Merge sort
The merge step compares the front items of two sorted sub-lists and takes the smaller each time, which is why merging is efficient. Splitting and merging means merge sort needs at most about operations, far fewer than bubble sort on large lists.
Comparing the two
Tracing a sort in the exam
Sort questions often ask you to show the list after each pass or each merge, so set your working out clearly. For a bubble sort, write the list at the start of each pass and after every swap, and note that after pass the largest values are in place at the end, so each pass can stop one position earlier. For a merge sort, draw the splitting as a tree down to single items, then show each merge of two sorted sub-lists, taking the smaller front item each time. Laying the trace out step by step earns method marks even if a single comparison slips, and it makes it obvious when the list is finally sorted.
Why efficiency matters
The reason the specification pairs a slow simple sort with a fast complex one is to make the efficiency point concrete. Bubble sort's roughly comparisons grow far faster than merge sort's roughly as the list lengthens, so the gap is tiny for a handful of items but enormous for millions. The trade-off is that merge sort needs extra memory for the temporary lists it builds while merging, whereas bubble sort sorts in place. So the right choice depends on the data: bubble sort for small or nearly sorted lists, merge sort when the list is large and speed matters more than memory.
Try this
Q1. Describe the main idea of a bubble sort. [2 marks]
- Cue. Repeatedly compare adjacent pairs and swap if in the wrong order, passing through the list until no swaps are made.
Q2. State the technique that merge sort is based on. [1 mark]
- Cue. Divide and conquer: split the list down to single items, then merge them back in order.
Exam-style practice questions
Practice questions written in the style of AQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
AQA 20194 marksTrace one complete pass of a bubble sort on the list [6, 2, 9, 4]. State the list after each swap and the list at the end of the pass.Show worked answer →
Compare adjacent pairs left to right, swapping when the left value is larger.
Compare 6 and 2: swap to give [2, 6, 9, 4]. Compare 6 and 9: no swap, [2, 6, 9, 4]. Compare 9 and 4: swap to give [2, 6, 4, 9].
After one full pass the list is [2, 6, 4, 9], and the largest value 9 has bubbled to the end (its correct place).
Markers reward correct adjacent comparisons, showing each swap, and the end-of-pass list with the largest value settled at the end.
AQA 20225 marksCompare bubble sort and merge sort in terms of how they work and their efficiency on a large list. Recommend which is more suitable for sorting one million records and justify your answer.Show worked answer →
Bubble sort repeatedly compares and swaps adjacent items, passing through the list until no swaps occur; it sorts in place with little extra memory but is slow, needing up to about comparisons. Merge sort uses divide and conquer: it splits the list down to single items then merges them back in order, needing about operations, but uses more memory for the temporary lists.
For one million records, merge sort is far more suitable: for bubble sort is around operations, whereas for merge sort is around , so merge sort finishes vastly faster. The extra memory is an acceptable cost for that speed.
Markers reward the method contrast, the efficiency figures ( versus ), and a justified recommendation tied to the large data size.
Related dot points
- Understand and explain how the linear search and binary search algorithms work, trace each one, and compare them including the requirement that binary search needs a sorted list.
A focused answer to AQA GCSE Computer Science 3.1.3, covering how linear search and binary search work, how to trace each one, and how they compare including why binary search needs a sorted list.
- Computational thinking through abstraction, decomposition and algorithmic thinking, and understanding what an algorithm is and the difference between an algorithm and a program.
A focused answer to AQA GCSE Computer Science 3.1.1, covering abstraction, decomposition and algorithmic thinking, what an algorithm is, and how an algorithm differs from a program.
- Represent and interpret algorithms using flowcharts and pseudocode, recognise the standard flowchart symbols, and read and write AQA-style pseudocode.
A focused answer to AQA GCSE Computer Science 3.1.2, covering how to represent algorithms with flowcharts and pseudocode, the standard flowchart symbols, and reading and writing AQA-style pseudocode.
- Use one-dimensional and two-dimensional arrays and records to store collections of data, and access elements using indexes and field names.
A focused answer to AQA GCSE Computer Science 3.2.6, covering one-dimensional and two-dimensional arrays and records, and accessing elements using indexes and field names.
Sources & how we know this
- AQA GCSE Computer Science (8525) specification — AQA (2020)