import java.util.Arrays;
public class QuickSort extends TriediaciAlgoritmus {
@Override
protected void utried(int odIdx, int poIdx) {
if (poIdx < odIdx)
return;
//rozdelenie podla pivota
int pivotIdx = rozdel(odIdx, poIdx);
//rekurzivne volanie
utried(odIdx, pivotIdx - 1);
utried(pivotIdx + 1, poIdx);
}
public int rozdel(int odIdx, int poIdx) {
int idx = odIdx;
for (int i = odIdx; i <= poIdx - 1; i++)
if (porovnaj(i, poIdx) < 0) {
vymen(i, idx);
idx++;
}
vymen(idx, poIdx);
return idx;
}
public static void main(String[] args) {
// int[] pole = new int[] {3, 9, 2, 7, 5, 4, 6, 11, 8, 4, 2};
// int[] pole = new int[] {1,2,4,5,3,7,8,10,11,9,6};
int[] pole = new int[] {11,10,9,8,7,6,5,4,3,2,1};
System.out.println(Arrays.toString(pole));
QuickSort qs = new QuickSort();
qs.utried(pole);
System.out.println(Arrays.toString(pole));
qs.vypisInfo();
}
}