资源描述:
《测量各排序算法的时间性能.doc》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、实验坏境,VC++6.0实验程序如下:#include#include#include#includeusingnamespacestd;voidBubbleSort(intr[],intn);//起泡排序voidSelectSort(intr[],intn);//简单选择排序voidQuickSort(intr[],intfirst,intend);//快速排序voidMergeSort1(intr[],intr1[],intn);//归并排序的非递归算法voidMergeSo
2、rt2(intr[],intr1[],intr2[],ints,intt);//归并排序的递归算法constintsize=100000;intmax=10000000,num[size];intg1[size];inth1[size];inth2[size];intmain(){//数组中的数据随机生成srand((unsigned)time(NULL));//cout<<"随机数组为:";for(inti=0;i3、nta[]={21,33,44,44,58,78,89,90,100,100,105,110,116,120,129,130,138,138,140,159,167,177,189,189,199,200,210,222,238,249,267,279,288,288,194,300,345,389,489,599,673,899,903,903,1003,1277,1390,1390,1789,1990};intb[1000],c[10000];for(intj=0;j<1000;j++)b[j]=j+10;for(intk=0;k<10000;k++
4、)c[k]=k+5;clock_tstart,end;cout<<"起泡排序结果为:";/*start=clock();BubbleSort(num,size);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<5、0);end=clock();cout<<"Thetimewas:"<<(double)(end-start)/CLK_TCK<6、)/CLK_TCK<7、"<<(double)(end-start)/CLK_TCK<8、ickSort(b,0,999);end=clock();cout<<"Thet