How do bubble, insertion, merge and quick sort work, and which is most efficient?
Sorting algorithms: bubble sort and insertion sort and their quadratic efficiency, merge sort and quick sort and their use of divide and conquer, and comparing sorting algorithms by time complexity and stability.
An Eduqas Component 1 answer on sorting: how bubble and insertion sort work and why they are quadratic, how merge sort and quick sort use divide and conquer to reach n log n, and comparing the algorithms by time complexity.
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
Eduqas wants you to describe bubble sort and insertion sort and explain why they are quadratic, describe merge sort and quick sort and their divide-and-conquer strategy, and compare the algorithms by time complexity. Sorting questions usually ask for a trace of one pass plus a complexity justification.
The answer
Bubble sort and insertion sort
Merge sort
Quick sort
Examples in context
Sorting underlies almost everything: arranging search results, ordering a leaderboard, or preparing data for a binary search (which needs sorted input). For small or nearly sorted lists, insertion sort is genuinely efficient; for large data, library routines use algorithms (often a quick sort or a hybrid). The divide-and-conquer idea in merge sort and quick sort reappears in the next dot point on recursion and Big-O, which formalises why halving the problem produces the factor.
Try this
Q1. State the worst-case time complexity of bubble sort and of merge sort. [2 marks]
- Cue. Bubble sort ; merge sort .
Q2. Give one advantage of insertion sort over bubble sort. [1 mark]
- Cue. It is efficient () on data that is already nearly sorted, since few shifts are needed.
Q3. Why can quick sort degrade to ? [1 mark]
- Cue. A poorly chosen pivot (for example always the smallest element) gives very unbalanced partitions, so the recursion depth grows to .
Exam-style practice questions
Practice questions written in the style of WJEC Eduqas exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
Eduqas 20195 marksThe list is to be sorted into ascending order using a bubble sort. Show the list after the first complete pass, and explain why bubble sort has a worst-case time complexity of .Show worked answer →
First pass (up to 3 marks): compare and swap adjacent out-of-order pairs left to right. swap; no swap; swap; no swap; swap. After one pass: , with the largest value bubbled to the end.
Complexity (up to 2 marks): there are up to passes, each making up to comparisons, so the work grows with , giving .
Markers reward the correct list after one pass (largest at the end) and the nested-pass reasoning for .
Eduqas 20216 marksExplain how merge sort uses a divide-and-conquer approach to sort a list, and state its time complexity. Give one advantage and one disadvantage compared with bubble sort.Show worked answer →
Divide and conquer (up to 3 marks): merge sort repeatedly splits the list in half until each sublist has one element (which is trivially sorted), then merges pairs of sorted sublists back together in order, repeating until one sorted list remains.
Complexity (up to 1 mark): the splitting gives levels and each merge level does work, so merge sort is .
Comparison (up to 2 marks): advantage, far faster than bubble sort's on large lists; disadvantage, it needs extra memory for the temporary sublists, whereas bubble sort sorts in place.
Markers reward the split-then-merge description, the complexity, and a valid advantage and disadvantage.
Related dot points
- Searching and traversal algorithms: linear search and binary search with their conditions and efficiency, and the breadth-first and depth-first traversals of trees and graphs.
An Eduqas Component 1 answer on searching: how linear search and binary search work, the precondition that binary search needs sorted data, their time complexities, and how breadth-first and depth-first traversals explore trees and graphs.
- Recursion and algorithmic complexity: the base case and recursive case, how recursion uses the call stack, and Big-O notation for the time and space complexity of algorithms (constant, logarithmic, linear, polynomial and exponential).
An Eduqas Component 1 answer on recursion and complexity: the base case and recursive case, how recursion uses the call stack and can cause stack overflow, and Big-O notation for measuring how an algorithm's time and space scale with input size.
- Dynamic data structures: stacks (LIFO) and queues (FIFO) with their push, pop, enqueue and dequeue operations and pointer management, linear and circular queues, and singly and doubly linked lists with insertion and deletion.
An Eduqas Component 1 answer on stacks, queues and linked lists: LIFO and FIFO behaviour, push, pop, enqueue and dequeue with pointer management, the wrap-around in a circular queue, and inserting and deleting nodes in a linked list.
- Static data structures: one- and multi-dimensional arrays, records (structs), tuples and sets, how they are stored contiguously in memory, address calculation for array elements, and choosing the appropriate structure for a task.
An Eduqas Component 1 answer on static data structures: one- and multi-dimensional arrays, records, tuples and sets, how they are stored contiguously in memory, calculating the address of an array element, and choosing the right structure for a problem.
- Trees, graphs and hash tables: binary search trees and their traversals (in-order, pre-order, post-order), graphs as adjacency matrices and adjacency lists, and hashing for direct-access tables including collision handling.
An Eduqas Component 1 answer on trees, graphs and hash tables: binary search trees and in-order, pre-order and post-order traversals, representing graphs with an adjacency matrix or adjacency list, and hashing for fast direct access with collision handling.