comparisons, where QC
j
DD
Cj , and for all feasible i and j , Ci is independent of QC
j .
The 1-stage now comes in, requiring additional comparisons to remove the remaining
inversions. When we are about to insert Y. j /, we place it among
fX.1/; : : : ; X. j /g [ fY.1/; : : : ; Y. j¡1/g:
Because the 2-stage has sorted the Y ’s, fY.1/; : : : ; Y. j¡1/g do not have any inversions with
Y. j /. Only fX.1/; : : : ; X. j /g can introduce inversions. It is well known that the so-called
sentinel version of insertion sort makes
C.5n/ D n C I .5n/
comparisons to sort a permutation 5n with I .5n/ inversions. Let Vj be the number of
inversions Y. j / makes with all the elements that precede it, that is
Vj D 1fX.1/>Y. j /g C¢ ¢ ¢C1fX. j />Y. j /g;