@@ -0,0 +1,840 @@
+/**%0A * Heap construction%0A * delMax() till empty%0A */%0Apublic class HeapSort %7B%0A%0A    public void sort(Comparable%5B%5D pq) %7B%0A        int N = pq.length;%0A        for (int i = N / 2; i %3E= 1; i--) %7B%0A            sink(pq, i, N);%0A        %7D%0A%0A        while (N %3E 1) %7B%0A            exch(pq, 1, N--);%0A            sink(pq, 1, N);%0A        %7D%0A    %7D%0A%0A    private void exch(Comparable%5B%5D pq, int i, int j) %7B%0A        Comparable temp = pq%5Bi%5D;%0A        pq%5Bi%5D = pq%5Bj%5D;%0A        pq%5Bj%5D = temp;%0A    %7D%0A%0A    private void sink(Comparable%5B%5D pq, int i, int j) %7B%0A        while (2 * i %3C= j) %7B%0A            int k = 2 * i;%0A            if (k %3C j && less(pq, k, k + 1)) k++;%0A            if (!less(pq, i, k)) break;%0A            exch(pq, i, k);%0A            i = k;%0A        %7D%0A    %7D%0A%0A    private boolean less(Comparable%5B%5D pq, int i, int k) %7B%0A        return pq%5Bi%5D.compareTo(pq%5Bk%5D) %3C 0;%0A    %7D%0A%0A%7D%0A

add heap sort