Site Search:

maze quiz 2

private int partition(int[] a, int lo, int hi) {
    int v = a[lo];
    int i = lo;
    int j = hi + 1;
    while(true) {
        while(a[++i] <= v) if(i == hi) break;
        while(a[--j] >= v) if(j == lo) break;
        exch(a, i, j);
    }
    exch(a, lo, j);
    return j;
}
private void sort(int[] a, int lo, int hi) {
    //what is missing here?
    int j = partition(a, lo, hi);
    sort(a, lo, j - 1);
    sort(a, j + 1, hi);
}