- = length()
- = number of times the while loop
*test*is executed for that value of

Insertion-Sort(A) |
Cost |
Times (Iterations) |

1 for j = 2 to length(A) | ||

2 key = A[j] | ||

3 i = j - 1 | ||

4 while i 0 and A[i] key | ||

5 A[i+1] = A[i] | ||

6 i = i - 1 | ||

7 A[i+1] = key |