24
0
8
1
42
2
15
3
6
4

The Jumbled Bubbles

Imagine these glowing circles are bubbles floating in a line. Right now, they are all mixed up! We want to organize them from smallest to biggest.

Who is Bigger?

We look at two neighbors. The Left Bubble (24) asks the Right Bubble (8): 'Hey, am I bigger than you?'

Switch Places!

Yes! 24 is bigger than 8. The big bubbles belong on the right side, so they have to swap spots. SWOOSH!

Bubbling Up

We keep checking neighbors. The biggest bubble (42) is like a heavy rock—it keeps swapping until it sinks all the way to the end of the line.

Safe Zone

Hooray! The biggest bubble (42) made it to the very end. It turns purple because it is 'locked' in its perfect safe spot. It won't move again.

Perfect Order

We do this again and again for the rest of the bubbles. Eventually, everyone finds their spot, and the line is perfectly organized!

Complete.

You have visualized the Bubble Sort current.

AlgoAnimator: Interactive Data Structures