Watch six sorting algorithms race through bars in real time — live comparison and swap counters, pseudocode line highlighting, and a complexity table make the difference between O(n²) and O(n log n) obvious.
Algorithm
Array
Comparisons
0
Swaps/writes
0
Step
0/1,722
Reads
0
Aux memory
0
Call depth
1/1
Slow the speed and use Step to match the pseudocode highlight with the bar colors.
Pseudocode
for i ← 0 to n−1
for j ← 0 to n−i−2
if a[j] > a[j+1]
swap a[j] ↔ a[j+1]
// a[n−1−i] 확정
Time complexity
| Best | O(n) |
|---|---|
| Average | O(n²) |
| Worst | O(n²) |
| Space | O(1) |
| Stable | Yes |