Bubble Sort

Watch elements bubble to their correct positions through comparison and swapping

Size:
Speed:
Unsorted
Comparing
Swapping
Sorted

About Bubble Sort

Time Complexity:

  • Best: O(n) - already sorted
  • Average: O(n²)
  • Worst: O(n²) - reverse sorted

Space Complexity: O(1)

Stable: Yes

How It Works

Bubble Sort repeatedly steps through the list, compares adjacent elements, and swaps them if they're in the wrong order.

The algorithm gets its name because smaller elements "bubble" to the top of the list (beginning) while larger elements sink to the bottom (end).

💡 Tip: Watch how the largest unsorted element moves to its correct position in each pass!