Вот мой код: р>
Код: Выделить всё
public class QuickSort {
public static void main(String[] args) {
int[] arr = {10, 7, 8, 9, 1, 5};
int n = arr.length;
QuickSort ob = new QuickSort();
ob.quick_Sort(arr, 0, n-1);
System.out.println("Sorted array:");
printArray(arr);
}
void quick_Sort(int[] arr, int low, int high) {
if (low < high) {
int pi = partition(arr, low, high);
quick_Sort(arr, low, pi-1);
quick_Sort(arr, pi+1, high);
}
}
int partition(int[] arr, int low, int high) {
int pivot = arr[high];
int i = (low-1);
for (int j = low; j < high; j++) {
if (arr[j]
Подробнее здесь: [url]https://stackoverflow.com/questions/78831812/quicksort-implementation-in-java-not-sorting-correctly[/url]