首页 > 代码库 > quicksort

quicksort

public void quicksort(int[] array, int low, int high){        int i = low;        int j = high;        if(i>j)            return;        int pivot = i + (j-i)/2;        int pnum = array[pivot];        while(i<=j){            // array[i] == pnum error. because have to be swap.            while(i<=j && array[i]<pnum)                i++;            while(i<=j && array[j]>pnum)                j--;            if(i<=j){            exchange(array,i,j);            i++;            j--;            }        }          // Recursion          quicksort(array,low, j);          quicksort(array,i, high);                    }