快速排序
2020-12-13 02:32
标签:else swap more 排序 static quicksort turn stat ati 快速排序 标签:else swap more 排序 static quicksort turn stat ati 原文地址:https://www.cnblogs.com/bigdata-stone/p/11042340.htmlpackage com.cisco.www.sort;
public class QuickSort {
public static void quickSort(int[] arr,int L,int R){
int[] p = partition(arr,L,R);
quickSort(arr,L,p[0]-1);
quickSort(arr,p[1]+1,R);
}
public static int[] partition(int[] arr,int L,int R){
int less = L -1;
int more = R+1;
int cur= L;
while (cur
}else if(arr[cur]>arr[R]){
swap(arr,--more,L);
}else {
cur++;
}
}
swap(arr,more,R);
return new int[]{less+1,more};
}
private static void swap(int[] arr, int i, int j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
下一篇:解决Linux下Svn检出Windows SVN服务器上项目SSL handshake failed: SSL error: Key usage violation in certificate