数据结构专业课程设计十种排序算法比较样本 下载本文

{t++;

if(first==0)first=n;

first--;

cache[first]=nu[i].key; s++; } else

{ t++;

for(j=first;nu[i].key>cache[j];) {

if(0==j)

cache[n-1]=cache[0];

else

cache[j-1]=cache[j];

s++;j++;

if(j==n)j=0; }

if(0==first)first=n-1;

else first--;

if(0==j)j=n;

cache[j-1]=nu[i].key; s++;

} } }

for(i=first,j=0;j

nu[j].key=cache[i]; i++;

if(i==n)i=0; }

cout<<\移动次数=\比较次数=\ }

//二路归并

void Merge(sqlist a, sqlist b, int low, int mid, int high) {

int i= low, j = mid + 1,k = low; while ((i <= mid) && (j <= high)) {

if(a[i].key <= a[j].key) { h++;

b[k++] = a[i++]; g++; ++i; } else { h++;