快速排序最优最精简代码
作者:互联网
public static void quickSort(int array[], int begin, int end) {
if (begin >= end)
return;
int keyIndex = begin;
int key = array[begin];
for (int i = begin + 1; i < end; i++) {
if (array[i] < key) {
keyIndex++;
int temp = array[keyIndex];
array[keyIndex] = array[i];
array[i] = temp;
}
}
array[begin] = array[keyIndex];
array[keyIndex] = key;
quickSort(array, begin, keyIndex);
quickSort(array, keyIndex + 1, end);
}
参考自作者:智者之行zip
标签:begin,end,int,quickSort,精简,最优,排序,array,keyIndex 来源: https://blog.csdn.net/kyc592/article/details/122394223