Comb Sort vs Shell Sort
Across our 3 test inputs, Shell Sort needed 79 comparisons in total versus 132 for Comb Sort. On average Comb Sort runs in O(n² / 2ᵖ) time and Shell Sort in Gap-dependent.
Head-to-head on identical inputs (comparisons)
| Input | Comb Sort | Shell Sort |
|---|---|---|
| Random order | 50 | 29 |
| Nearly sorted | 41 | 23 |
| Reversed | 41 | 27 |
Complexity
| Comb Sort | Shell Sort | |
|---|---|---|
| Average time | O(n² / 2ᵖ) | Gap-dependent |
| Worst time | O(n²) | O(n²) |
| Space | O(1) | O(1) |
| Stable | No | No |
When to use Comb Sort
A simple, low-memory improvement over Bubble Sort for small-to-medium arrays.
When to use Shell Sort
Medium-sized arrays and embedded systems where recursion or extra memory is undesirable.