快速排序
来源:互联网 发布:数据标准化是什么意思 编辑:程序博客网 时间: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);
}
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);
}
阅读全文
0 0
- 快速排序
- 快速排序
- 快速排序
- 快速排序!
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- [转]普通GPIO口模拟SPI通信协议
- HBase scan setBatch和setCaching的区别
- python里怎么终止程序的执行
- WOJ1032-Find the Max NORM
- Linux中Makefile的使用
- 快速排序
- 我以亲身经历告诉你崔廉正不是骗子
- 【SPSS】统计功能与模块对照表
- linux查看日志
- R语言下载gganimate包
- css+div总结
- json数据类型 导致(xxx).ToLowerCase isnot a function
- 【.ISO】一份来自2017年的.ISO
- ss命令详解