public class QuickSort {
public static void quickSort(int[] tab, int lowIndex, int highIndex) {
if (tab.length == 0 || tab == null) {
return;
}
int i = lowIndex;
int j = highIndex;
int pivot = tab[tab.length / 2];
while (i <= j) {
while (tab[i] < pivot) {
i++;
}
while (tab[j] > pivot) {
j--;
}
if (i <= j) {
int c = tab[i];
tab[i] = tab[j];
tab[j] = c;
i++;
j--;
}
if (lowIndex < j) {
quickSort(tab, lowIndex, j);
}
if (i < highIndex) {
quickSort(tab, i, highIndex);
}
}
}
public static void main(String[] args) {
int[] t = new int[] { 1, 3, 2, 5, 1, 2, 7 };
quickSort(t, 0, t.length - 1);
for (int i : t) {
System.out.print(i);
}
}
}
Błąd w 30 linijce, co jest źle ?
Pozdrawiam