BeginnerAbout 10 min
Bubble Sort
Read the full article on Substack
5 min read.
The simplest sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. "Bubbling" the largest element to the top.
Think of it this way: Imagine air bubbles in water. Heavier ones sink, lighter ones float up. In Bubble Sort, the largest element 'bubbles up' to the end of the list in each pass.
Start: 7 values. Each pass bubbles the largest unsorted value to the right.
1/52
Check your understanding
Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.
One pass of bubble sort
Sequence
Order what happens during a single pass.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
- 1Drop a step here
- 2Drop a step here
- 3Drop a step here
- 4Drop a step here
- 5Drop a step here
5 pieces left to place
Quiz
20 questionsQuestion 1 of 20
Score: 0
What is the worst-case time complexity of Bubble Sort?
Done with this lesson?
Sign in free to keep your progress, streak and quiz scores.