Sorting Algorithms
Aligned to the OCR J277 specification
- Topic
- Algorithms
- Level
- Intermediate
- Reading time
- 9 min
- Published
- 11 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- Bubble sort repeatedly compares and swaps adjacent pairs; after each pass the largest unsorted element is in its final position, and the algorithm can stop early if a pass produces no swaps.
- Insertion sort builds a sorted section from the left by taking each new element and inserting it into the correct position; it is efficient when the list is already nearly sorted.
- Merge sort uses divide and conquer - it splits the list in half until every sub-list has one element, then merges pairs back in order; it is efficient on large lists but requires extra memory for temporary sub-lists.
- A common mistake when merging is to concatenate the two sub-lists; instead, always compare the front elements of each sub-list and take the smaller one.
Something not quite clicking?
Ask Aica to explain any part of this differently. Free, takes 30 seconds.
Key terms
- Bubble sort
- A sorting algorithm that repeatedly compares and swaps adjacent elements in the wrong order; after each pass, the largest unsorted element moves to its final position.
- Insertion sort
- A sorting algorithm that maintains a sorted section and inserts each new element from the unsorted section into its correct position in the sorted section.
- Merge sort
- A divide-and-conquer sorting algorithm that splits a list into halves until each sub-list has one element, then merges pairs of sub-lists back together in order.
- Pass
- In bubble sort, one full iteration through the list comparing adjacent pairs; after each pass the largest unsorted element is in its correct place.
- Key
- In insertion sort, the element being taken from the unsorted section and inserted into its correct position in the sorted section.
- Divide and conquer
- A strategy that breaks a problem into smaller sub-problems, solves each, then combines the results; used by merge sort.
- Sub-list
- A smaller list produced during the divide stage of merge sort; sub-lists of size one are trivially sorted.
Frequently asked questions
Insertion sort is best for nearly sorted data because few elements need to be shifted, making it very efficient in that case. Bubble sort can also exit early if no swaps occur in a pass.
Look for key clues: swapping adjacent elements means bubble sort; inserting each element into a sorted section means insertion sort; splitting into halves and merging back means merge sort.
Merge sort creates temporary sub-lists during the divide and merge stages. These extra lists require additional memory, unlike bubble sort and insertion sort which sort in place without needing temporary storage.
Generate revision on any topic you study
Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.
Lessons on anything
Structured, level-matched lessons on any topic you study
Practice quizzes
Find out what you actually know before the exam does
Flashcard sets
Lock in key concepts with instant revision cards
Ask Aica
Stuck on something? Get a clear explanation, any time
Searching Algorithms
Programming Fundamentals
Related lessons
8 min
7 min
6 min
8 min