1 2 3 4 5 6 7 8 9 10 11 12 13 14
| void BInsertSort(SqList &L){ int i, j; for(i = 2; i <= L.length; i++){ L.r[0] = L.r[i]; int Low = 1, High = i - 1, Mid; while(Low <= High){ Mid = (Low + High) / 2; if(L.r[0].key < L.r[Mid].key) High = Mid - 1; else Low = Mid + 1; } for(j = i - 1; j >= High + 1; j--) L.r[j + 1] = L.r[j]; L.r[High + 1] = L.r[0]; } }
|