How do the bubble sort and merge sort algorithms put data into order, and how do they compare?
The bubble sort and merge sort algorithms, how each puts data into order, and the relative efficiency of the two methods.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on sorting algorithms, covering how the bubble sort works by repeatedly swapping adjacent items, how the merge sort works by splitting and merging, and the relative efficiency of the two methods with worked examples.
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 topic is asking
WJEC wants you to know how the bubble sort and merge sort algorithms put data into order and how they compare for efficiency. This is part of the Algorithms and programming principles content in Unit 1 of WJEC GCSE Computer Science (3500).
Bubble sort
Merge sort
How the two compare for efficiency
Choosing a sort
A bubble sort is fine for small lists or when simplicity matters more than speed, and it is a good way to learn how sorting works. A merge sort is far better for large lists, where its faster growth in efficiency saves a lot of time despite its greater complexity and memory use. The right choice depends on the size of the data and whether speed or simplicity matters more, and on whether the extra memory a merge sort needs is available.
Try this
Q1. State what a bubble sort does when it finds an adjacent pair in the wrong order. [1 mark]
- Cue. It swaps the two items.
Q2. State one advantage of a merge sort over a bubble sort. [1 mark]
- Cue. It is much faster (more efficient) on large lists.
Exam-style practice questions
Practice questions written in the style of WJEC exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
WJEC-style Unit 14 marksDescribe how a bubble sort puts a list of numbers into ascending order.Show worked answer →
A Unit 1 algorithms question. A bubble sort works by comparing each pair of adjacent items in the list (1 mark). If a pair is in the wrong order (the left one is larger when sorting ascending), the two are swapped (1 mark). It makes repeated passes through the list, and after each pass the largest remaining value has "bubbled" to its correct place at the end (1 mark). The algorithm repeats until a complete pass is made with no swaps, meaning the list is sorted (1 mark). Markers reward comparing adjacent items, swapping out-of-order pairs and repeating passes until no swaps. A common error is to forget that several passes are needed, or to compare non-adjacent items.
WJEC-style Unit 13 marksExplain why a merge sort is usually more efficient than a bubble sort on a large list.Show worked answer →
A Unit 1 comparison question. A merge sort uses a divide-and-conquer approach: it repeatedly splits the list into smaller and smaller parts until each part has one item, then merges the parts back together in order (1 mark). This means the number of operations grows much more slowly as the list size increases than for a bubble sort, which repeatedly compares adjacent items (1 mark). On a large list a merge sort therefore does far fewer comparisons and is much faster, although it is more complex to write and uses more memory (1 mark). Markers reward the split-and-merge method and the slower growth in operations on large lists. A common error is to say a bubble sort is faster because it is simpler, confusing simplicity with efficiency.
Related dot points
- Computational thinking through decomposition and abstraction, what an algorithm is, and expressing algorithms using flowcharts and pseudocode.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on computational thinking and algorithms, covering decomposition and abstraction, what an algorithm is, and how algorithms are expressed using flowcharts (with the standard symbols) and pseudocode, with worked examples.
- The linear search and binary search algorithms, how each works, and the conditions under which each is suitable.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on searching algorithms, covering how the linear search and binary search work step by step, the requirement that binary search needs sorted data, and the relative efficiency of the two methods with worked examples.
- The three programming constructs (sequence, selection and iteration), the use of variables and constants, and arithmetic, relational and logical operators.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on programming constructs, covering sequence, selection and iteration (including IF statements and FOR and WHILE loops), the difference between variables and constants, and arithmetic, relational and logical operators with worked examples.
- The use of subprograms (procedures and functions) and parameters, and the benefits of a modular, structured approach to programming.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on subprograms and program structure, covering procedures and functions, the use of parameters, the difference between a procedure and a function, and the benefits of a modular, structured approach to writing programs.
- The common data types, the use of data structures such as arrays and records, and the difference between validation and verification.
A focused answer to the WJEC GCSE Computer Science Unit 1 content on data organisation, covering the common data types (integer, real, Boolean, character and string), data structures such as arrays and records, and the difference between validation and verification with examples of each technique.