逻辑图
代码
public void quickSort(int[] array, int start, int end) {
if (start >= end) {
return;
}
int index = partition(array, start, end);
quickSort(array, start, index - 1);
quickSort(array, index + 1, end);
}
public int partition(int[] array, int start, int end) {
int pivot = array[end];
int index = start;
for (int i = start; i <= end - 1; i++) {
if (array[i] < pivot) {
int temp = array[i];
array[i] = array[index];
array[index] = temp;
index++;
}
}
int temp = array[end];
array[end] = array[index];
array[index] = temp;
return index;
}