Insertion Sort vs Selection Sort
Insertion Sort vs Selection Sort compares two simple O(n²) algorithms with very different personalities. Insertion Sort is adaptive and stable; Selection Sort is neither, but it makes the fewest swaps of any sort. The right choice depends on whether reads or writes dominate your cost.
The key differences
| Property | Insertion Sort | Selection Sort |
|---|---|---|
| Best case | O(n) | O(n²) |
| Adaptive | Yes | No |
| Stable | Yes | No |
| Swaps | Up to O(n²) | Exactly n-1 |
When to choose each
Choose Insertion Sort almost always — it is adaptive, stable, and fast on small or nearly-sorted data. Choose Selection Sort only when writes are extremely expensive (such as flash memory wear), because it guarantees the minimum number of swaps.
Frequently asked questions
Which is better, Insertion Sort or Selection Sort? +
Why does Selection Sort make fewer swaps? +
See it in motion
Watch this algorithm and 9 others run step by step in our free interactive visualizer.
▶ Launch Visualiser