0
如何逐步計算Shell排序算法的運行時間?如何計算Shell排序算法的運行時間
shellsort(itemType a[], int l, int r){
int i, j, k, h;
itemType v;
int incs[16] = { 1391376, 463792, 198768, 86961, 33936,
13776, 4592, 1968, 861, 336,
112, 48, 21, 7, 3, 1 };
for (k = 0; k < 16; k++)
{
for (h = incs[k], i = l+h; i <= r; i++)
{
v = a[i]; j = i;
while (j >= h && a[j-h] > v)
{
a[j] = a[j-h];
j -= h;
}
a[j] = v;
}//end inner-for loop
}//end outer for-loop
}//end shellsort
你能提供** l **和** r **的樣本值嗎? –