- 0
- 0
- 约1.1万字
- 约 4页
- 2026-02-05 发布于北京
- 举报
排序排序voidheapSift(ElementTypeR[],i
voidInsertionSort(Elenti,intN){ElementTypeTmp;i
mentTypeA[],intN){intj,P;ntChild;Tmp=R[i];Child=2*i;
ElementTypeTmp;for(P=1;Pwhile(Child=N){if(ChildNR[
N;P++){;for(j=P;j0A[j‑Child]R[Child+1]);if(TmpR[
1]Tmp;j‑‑);;}}Child])break;;;;}R[i]=Tmp;}
希尔排序希尔排序
voidShellsort(ElementTypeA[],
intN){inti,j,Increment;
ElementTypeTmp;f
or(Increment=N/2;Increment0;归并排序归并排序
Increment/=2)for(i=IncreVoidMSort(ElementTypeA[],
ment;iN;i++){;for(j=i;j=ElementTypeTmpArray[],int
Increment;j‑=Increment)if(TLeft,intRight){intCenter;if(
mpA[j‑Increment]);elseLeftRight){Center=(Left+
break;;}}Right)/2;MSort(A,TmpArray,
Left,Center);MSort(A,T
mpArray,Center+1,Right);
Merge(A,TmpArray,Left,Center
+1,Right);}}voidMergesort(
堆排序堆排序ElementTypeA[],intN){
voidheapSort(ElementTypeR[],ElementType*TmpArray;
intN){inti;ElementTypex;TmpArray=malloc(N*sizeof(
for(i=N/2;i=1;i‑‑);for(i=N;i1;ElementType));if(TmpArray!=
i‑‑){;;;;}}NULL){MSort(A,TmpArray,0,N‑
1);free(TmpArray);}elseprintf(
没有空间分配临时数组!!!);}
InsertionSort排序voidheapSift(ElementTypeR[],inti,int
voidInsertionSort(ElementTypeA[],N)
intN){
{ElementTypeTmp;
intj,P;
原创力文档

文档评论(0)