Insertion Sort
1/0
1.0x
Insertion Sort
O(n²)
Space: O(1)
Pseudocode
1
procedure insertionSort(A: list)
2
for i ← 1 to length(A) - 1 do
3
key ← A[i]
4
j ← i - 1
5
while j ≥ 0 and A[j] > key do
6
A[j+1] ← A[j]
7
j ← j - 1
8
A[j+1] ← key
9
return A
Random Input