Showing AQAChange board

Bubbles Rising to the Top

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

Bubbles Rising to the Top

Bubble sort is named after bubbles rising in water. It compares two neighbouring items, swaps them if they are in the wrong order, and moves along the list. After one full run (a pass), the largest value has "bubbled up" to the end. It keeps making passes until the list is sorted.

Bubble sort flowchart with two loops. Start, input the array, set i to 0. While i is less than n minus 1, set j to 0. While j is less than n minus i minus 1, test whether array[j] is greater than array[j+1]. If yes, swap the two items. Then, whether yes or no, add 1 to j and test again. When the j test fails, add 1 to i and test i again. When the i test fails, output the sorted array and end.

This is the bubble sort flowchart. It uses two loops: i counts the passes and j moves along the list comparing neighbouring items.

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.