OCR GCSE Computer Science · Component 2

🏁 Sorting Race

Watch algorithms in action, predict the next step, and answer exam questions

Score 0
Round 1 / 10
Streak 0 🔥
BUBBLE SORT Ready
Speed
Array state
Press Play or Next to begin stepping through Bubble Sort.
Step 0
MERGE SORT Ready
Speed
Merge tree
Press Play or Next to begin stepping through Merge Sort.
Step 0
Bubble Sort
  • Compare adjacent pairs, left to right
  • If the left value > right value, swap them
  • After each full pass, the largest unsorted value "bubbles" to the end
  • Repeat until no swaps occur in a full pass (sorted!)
Merge Sort
  • Divide the list in half repeatedly until each sublist has 1 element
  • A list of 1 is already sorted
  • Merge pairs of sorted sublists by comparing the front elements
  • Repeat merging until one fully sorted list remains

Comparison Table

Bubble Sort Merge Sort
Best case O(n) — already sorted O(n log n)
Worst case O(n²) O(n log n)
Memory O(1) — in-place O(n) — extra space
Stable? Yes Yes
Good for Small / nearly sorted lists Large lists
🏁

Sorting Algorithms

Sorting is arranging a list into order (usually smallest to largest). The OCR spec requires you to understand and trace two algorithms: Bubble Sort and Merge Sort.

🫧 Bubble Sort

Compare neighbours. Swap if out of order. Repeat. Simple but slow for large lists.

🔀 Merge Sort

Split the list in half, sort each half, merge them back together. Fast but uses extra memory.

🎉