Skip to content

Bubble sort

Put the smallest time first

  • Three race times sit in an array: 14, 9, 11. The smallest should come first.
  • Compare each pair of neighbours. When the left one is larger, swap them.
  • That single comparison does not finish the list. The next pair is compared after it.

Bubble sort compares neighbours: 14 is larger than 9, so those two swap; 11 is not in this comparison

Handout

Log in or create account

IGCSE, A-Level & AP