Insertion Sort
InsertionSort(A, n) {for i = 2 to n { key = A[i] j = i - 1; while (j > 0) and (A[j] > key) { A[j+1] = A[j] j = j - 1 } A[j+1] = key}
}
How many times will this loop execute?
Previous slide
Next slide
Back to first slide
View graphic version