Selection Sort vs Comb Sort

Across our 3 test inputs, Comb Sort needed 132 comparisons in total versus 135 for Selection Sort. On average Selection Sort runs in O(n²) time and Comb Sort in O(n² / 2ᵖ).

Head-to-head on identical inputs (comparisons)

InputSelection SortComb Sort
Random order4550
Nearly sorted4541
Reversed4541

Complexity

Selection SortComb Sort
Average timeO(n²)O(n² / 2ᵖ)
Worst timeO(n²)O(n²)
SpaceO(1)O(1)
StableNoNo

When to use Selection Sort

When memory writes are expensive (minimizes swaps). Otherwise, insertion sort is generally preferred.

When to use Comb Sort

A simple, low-memory improvement over Bubble Sort for small-to-medium arrays.