← Back to DSA Visualizer

Bubble Sort Visualization

Bubble Sort repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.

Time Complexity

Best: O(n)

Average: O(n²)

Worst: O(n²)

Space Complexity

O(1)

Comparisons

0

Swaps

0

500ms
0
Progress: 0 / 00%
Unsorted
Comparing
Swapping
Sorted

How Bubble Sort Works

Algorithm Steps:

  1. 1. Start at the beginning of the array
  2. 2. Compare adjacent elements
  3. 3. If they are in wrong order, swap them
  4. 4. Continue until end of array
  5. 5. Repeat until no swaps needed

Key Properties:

  • • Simple to understand and implement
  • • Stable sorting algorithm
  • • In-place sorting (O(1) space)
  • • Inefficient for large datasets
  • • Best for educational purposes