Bubble Sort

Back to Comparison-Based

Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. Simple but inefficient at O(n^2). Useful for educational purposes and nearly-sorted data.

algorithms sorting bubble-sort