@@ -0,0 +1,1218 @@
+package me.alivecode.algs4;%0A%0Aimport edu.princeton.cs.algs4.StdIn;%0Aimport edu.princeton.cs.algs4.StdOut;%0A/**%0A * Heap ordered queue for sorting.%0A */%0Apublic class Heap %7B%0A    private Heap() %7B%7D%0A%0A    /* %0A     * Heap ordered queue is one-based. %0A     * Heap sort uses zero-based array and %0A     * SortUtil's helper methods take zero-based array. %0A     * So we should off-by-one when passing heap queue's keys to thoes methods. %0A     */%0A%0A    private static void sink(Comparable%5B%5D a, int n, int k) %7B%0A        while(k*2%3C= n) %7B%0A            int j = k * 2;%0A            if (j %3C n && SortUtil.less(a%5Bj-1%5D, a%5Bj%5D)) j++;%0A            if (!SortUtil.less(a%5Bk-1%5D, a%5Bj-1%5D)) break;%0A            SortUtil.exch(a, k-1, j-1);%0A            k = j;%0A        %7D%0A    %7D%0A%0A    public static void sort(Comparable%5B%5D a) %7B%0A        int n = a.length;%0A        for(int k = n/2; k %3E= 1; k--) %7B%0A            sink(a, n, k);%0A        %7D%0A        while(n %3E 1) %7B%0A            // Move the max key to the end of array.%0A            SortUtil.exch(a, --n, 0);%0A            sink(a, n, 1);%0A        %7D%0A        assert SortUtil.isSorted(a);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        String%5B%5D a = StdIn.readAllStrings();%0A        sort(a);%0A        SortUtil.show(a);%0A    %7D%0A%7D%0A

Add heap sort.