Bubbles Rising to the Top

Part of Bubble Sort · Section 1 of 7

IntroductionUnit: 3.1 Fundamentals of AlgorithmsGCSE

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.

This introduction covers Bubbles Rising to the Top within Bubble Sort for GCSE Computer Science. Revise Bubble Sort in 3.1 Fundamentals of Algorithms for GCSE Computer Science with 16 exam-style questions and 10 flashcards. This topic appears regularly enough that it should still be part of a steady revision cycle. It is section 1 of 7 in this topic. Use this introduction to connect the idea to the wider topic before moving on to questions and flashcards.

Practice questions for Bubble Sort

Which of the following best describes bubble sort?

  • A. It selects the smallest element and moves it to the front each pass
  • B. It compares adjacent elements and swaps them if they are in the wrong order
  • C. It divides the list in half repeatedly until each half is sorted
  • D. It inserts each element into its correct position one at a time
1 markfoundation

Describe how bubble sort works. You should refer to what happens during each pass through the list. [3 marks]

3 marksstandard

Quick recall flashcards

How does bubble sort work?
Compare adjacent pairs, swap if wrong order, repeat passes
Why is it called bubble sort?
Largest values bubble up to the end like bubbles rising in water

16 questions on Bubble Sort: practise free

Instant marking, adaptive difficulty and spaced-repetition flashcards — all aligned to your exam board.

Start revising free →

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.