1 / 24
Settings
<<<>>>
We first examine the worst case cost.
- static <T extends Comparable<T>> void inssort(T[] A) {
- for (int i=1; i<A.length; i++) // Insert i'th record
- for (int j=i; (j>0) && (A[j].compareTo(A[j-1]) < 0); j--)
- swap(A, j, j-1);
- }
- 60
- 51
- 42
- 33
- 24
- 15
i=1
i=2
i=3
i=4
i=5
n−1
n−1