Showing AQAChange board

Deep Dive: Bubble Sort Trace

Test yourself on Bubble Sort with exam style questions, marked instantly.

Flashcards that come back just before you would forget them.

A revision plan that remembers what you know and shows what to do next.

See which topics you have nailed and which need another look.

Quiz yourself on Bubble SortGet your flashcardsBuild my revision planTrack my progress

Deep Dive: Bubble Sort Trace

Sort [4, 2, 3, 1] into ascending order:

Pass 1:

  • Compare 4 and 2: swap, giving [2, 4, 3, 1]
  • Compare 4 and 3: swap, giving [2, 3, 4, 1]
  • Compare 4 and 1: swap, giving [2, 3, 1, 4]. The 4 is now in its final place.

Pass 2:

  • Compare 2 and 3: no swap
  • Compare 3 and 1: swap, giving [2, 1, 3, 4]

Pass 3:

  • Compare 2 and 1: swap, giving [1, 2, 3, 4]

The list is now in order. A further pass would make no swaps, which is how the algorithm knows it can stop.

Make this stick

Signing in gives access to all PrepWise features.

PrepWise is a trading name of A3M Quality Solutions Limited, registered in England and Wales, company number 14959172. Registered office: 202 Stroud Road, Gloucester, GL1 5LA. ICO registration ZC267069.