Sorting visualizer

Bubble Sort

Compare adjacent values and bubble larger values to the end.

Example Array
[42, 17, 8, 33, 25, 11, 60, 29]

Visualization

Ready
ComparingMoving / writingPivotSorted

Bubble Sort is ready to compare adjacent values.

Metrics

Comparisons0
Swaps0
Progress0%
Time taken0.0s

Pseudocode

  1. for pass from 0 to n - 2
  2. swapped = false
  3. for i from 0 to n - pass - 2
  4. if arr[i] > arr[i + 1]
  5. swap arr[i] and arr[i + 1]
  6. return arr

About Bubble Sort

Bubble Sort repeatedly compares neighboring values and swaps them when they are out of order. Each pass places the largest remaining value at the end of the unsorted section.

Sorted Output

[ 8, 11, 17, 25, 29, 33, 42, 60 ]

Complete the visualization to reach this output.

Complexity Overview

Best CaseO(n)
Average CaseO(n²)
Worst CaseO(n²)
SpaceO(1)
StableYes