Quick sort, like bubble sort, is also a kind of exchange sort.
The criterion of quick sort is "find the base number, separate the size; divide and conquer, recursive use". The basic code is as follows:
public static void quickSort(int[]arr,int start,int end){
if(start < end){
int stard = arr[start]; //找到基准数
int low = start; //定义排序下标和上标
int high = end;
while(low < high){
while(low < high && stard <= arr[high]){
high--;
}
arr[low] = arr[high];
while(low < high && stard >= arr[low]){
low++;
}
arr[high] = arr[low];
}
arr[low] = stard; //第一轮排序结束
quickSort(arr,start,low); //递归调用
quickSort(arr,low+1,end);
}
}