Module · Sorting

Sorting Algorithm Visualizer

Watch comparisons, swaps, and sorted regions unfold in real time.

77
23
70
59
95
49
30
17
36
15
Comparing Swapped Sorted

Comparisons

0

Swaps

0

Current Step

0

Algorithm

Bubble Sort

Operation History

  • #1Generated a random array for sorting.

Time Complexity

Bubble Sort

Best
O(n)
Average
O(n²)
Worst
O(n²)
Space
O(1)

How It Works

Bubble Sort repeatedly compares adjacent elements and swaps them if they are in the wrong order. Larger values gradually "bubble" toward the end of the array.

Yellow bars indicate elements being compared. Green bars show a swap in progress. Blue bars mark elements already in their final sorted position.