Java
0
Вклад в тег
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
int t = arr[i+1];
arr[i+1] = arr[r];
arr[r] = t;
public static int[] quickSort(int arr[], int p, int r){
if(p < r){
int q = partition(arr, p, r);
quickSort(arr, p, q-1);
quickSort(arr, q+1, r);
}
return arr;
}
private static int partition(int[] arr, int p, int r) {
int x = arr[r];
int i = p-1;
for (int j = p; j < r; ++j){
count++;
if(arr[j] < x){
i++;
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
System.out.println(Arrays.toString(arr));
}
int t = arr[i+1];
arr[i+1] = arr[r];
arr[r] = t;
return i+1;
}