Insertion Sort
Insertion sort slides each new item leftward into a sorted prefix. Nearly sorted input does little sliding.
Costs
| Category | Algorithm |
| Difficulty | Easy |
| Worst and average | O(n²) |
| Already nearly sorted | O(n) |
| Extra memory | O(1) |
Questions
What is Insertion Sort?
Insertion sort slides each new item leftward into a sorted prefix. Nearly sorted input does little sliding.
Where do I practice it?
DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.