Bubble Sort Algorithm Visualizer

Normal
Comparing
Swapping
Sorted
Click "Start Sorting" to begin the visualization.

How Bubble Sort Works

Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.

Algorithm Steps:

  1. Start at the beginning of the array
  2. Compare the current element with the next one
  3. If they are in the wrong order, swap them
  4. Move to the next pair
  5. Repeat until no more swaps are needed

Time Complexity:

Case Time Complexity
Best Case (Already sorted) O(n)
Average Case O(n²)
Worst Case (Reverse sorted) O(n²)

Characteristics: