← Back to Lab
Computer Science · Topic 7 · Algorithm design & problem-solving

Bubble sort. Watch it bubble.

Step through bubble sort comparison by comparison — every swap counted, the sorted tail growing pass by pass. Switch to linear search and watch it scan. These are the two standard algorithms the syllabus names.

0478 Topic 7 — Algorithms bubble sort · linear search · dry runs
Ready — press Step to make one comparison, or Run to animate.

Variables

9
4

Dry-run counters

Comparisons
0
Swaps
0
Pass
0
Status
idle
Bubble sort compares NEIGHBOURS and swaps them if they are in the wrong order. After each pass, the largest unsorted value has "bubbled" to the end.
📋 Bubble sort (Cambridge)
  • Compare each pair of NEIGHBOURING values; swap if the left one is bigger (ascending sort).
  • One full sweep of the list is a pass; after pass 1 the largest value is at the end.
  • Repeat passes until a complete pass makes no swaps — the list is sorted.
  • Each pass can ignore the already-sorted tail (shown green) — one fewer comparison every pass.
🔎 Linear search
  • Check each value in turn, from the first, until the target is found or the end is reached.
  • Works on unsorted lists — no preparation needed.
  • Worst case: the target is last (or absent), so every value is checked.
🎯 Syllabus reference (0478)
  • Topic 7 — Algorithm design and problem-solving: standard methods of solution including bubble sort, linear search, counting and totalling; dry-run algorithms using trace tables; suggest test data.

Ask the lab assistant