Comb Sort vs Bubble Sort
Same 110 values, same shuffle, same speed. Comb Sort finishes first and turns gold: 1,615 operations to 8,678.
The numbers
- Comb operations
- 1,615
- Bubble operations
- 8,678
- Comb average
- n²/2^p
- Bubble average
- n²
- Comb worst
- n²
- Bubble worst
- n²
Comb Sort
Comb Sort is Bubble Sort with a shrinking gap: it compares values far apart first, then closer ones. More on Comb Sort.
Bubble Sort
Bubble Sort walks through the list swapping neighbours that are out of order, until a pass makes no swaps. More on Bubble Sort.
FAQ
Which is faster, Comb Sort or Bubble Sort?
On this shuffle of 110 values, Comb Sort needed 1,615 operations and Bubble Sort needed 8,678, about 5.4× as many. On average Comb Sort is n²/2^p and Bubble Sort is n².
Which one is stable?
Bubble Sort is stable; Comb Sort is not.
How is the race fair?
Both algorithms start from the same shuffle and run the same number of operations per frame. Every comparison, swap and write counts as one operation, so the one that needs fewer operations finishes first.