Bubble sort
Bubble sort · O(n²)
Elements Active CompletePlayed 0.0 s · same input
Bubble sort
Bubble sortOperations0
Comparisons0
Writes0
Each comparison or write counts as 1 operation. Playback time is not execution time.
← Back to six-algorithm comparisonHow it works +
Compare adjacent elements and swap larger values to the right. Each pass bubbles the largest remaining value to the end. A pass without swaps ends the sort early.
Extra space: O(1); Stable. Each comparison or main-array write counts as 1 operation.