排序算法——折半排序

void BinarySort(SqList &L) //折半排序算法
{
int low=0;
int high=0;
int mid=0;
int i,j;
int key;
clock_t start;
clock_t finish;
double time;
start=clock();

for(i=1;iL.elem[mid])
        {
            low=mid+1;
            high=high;
        }
        else
        {
            low=low;
            high=mid-1;
        }
    }
    for(j=i-1;j>=high+1;j--)
    {
        L.elem[j+1]=L.elem[j];
    }
    L.elem[j+1]=key;
}
finish=clock();
time=(double)(finish-start)/CLOCKS_PER_SEC;
printf("%f seconds\n",time);

}

你可能感兴趣的:(排序算法——折半排序)