返回信息流c是比较次数 现在这种有问题
int Partion(int r[],int first,int end)
{
int i=first;
int j=end;
int pivot=r[i];
while(i<j)
{
while((i<j)&&(r[j]>=pivot))
{
j--;
c++;
}
c++;
r[i]=r[j];
m++;
while((i<j)&&(r[i]<=pivot))
{ i++;
c++;
}
c++;
r[j]=r[i];
m++;
}c++;
r[i]=pivot;m+=2;
return i;
}
void QuickSort(int r[],int i,int j)
{
if(i<j)
{
int pivotloc=Partion(r,i,j);
QuickSort(r,i,pivotloc-1);
QuickSort(r,pivotloc+1,j);
}
}
这是一条镜像帖。来源:北邮人论坛 / cpp / #89712同步于 2015/12/13
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
快速排序如何记录比较次数
bluesun
2015/12/13镜像同步2 回复
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复