快速排序

来源:互联网 发布:数据标准化是什么意思 编辑:程序博客网 时间:2024/05/24 05:51
public static void sort(int[] a,int low,int high){
int i,j;
int index;
if(low>=high)
return;
i=low;
j=high;
index=a[i];
while(i<j){
while(i<j&&a[j]>=index)
j--;
if(i<j)
a[i++]=a[j];
while(i<j&&a[i]<index)
i++;
if(i<j)
a[j--]=a[i];
}
a[i]=index;
sort(a,low,i-1);
sort(a,i+1,high);

}
public static void quickSort(int[] a){
sort(a,0,a.length-1);
}