Insertion Sort
Efficient algorithm for sorting a small number of algorithms. If the array is sorted, the runtime is reduced to .
High Level Idea: We go from left to right.
- Find where
x
should go - Shift elements that are greater
x
- Insert
x
- Repeat
Insertion Sort Pseudocode#card
Time Complexity
- Best Case:
- Average Case:
- Worst Case:
Space Complexity
- Worst Case: