Heap { public void buildMaxHeap(List<T> A, Comparator<T> comp, int n) { for (int i = ((n/2)-1); i >= 0; i--) maxHeapify(A, comp, i, n); }  static void heapsort(List<T> A, Comparator<T> comp); static void heapsort(List<Integer> A); void heapsort(List<T> A, Comparator<T> comp, int n); void maxHeapify(List<T> A, Comparator<T> comp, int i, int n); void buildMaxHeap(List<T> A, Comparator<T> comp, int n);  }
@Test public void testBuildMaxHeap() { System.out.println("testBuildMaxHeap entry."); List<Integer> before = Arrays.asList(4, 1, 3, 2, 16, 9, 10, 14, 8, 7); List<Integer> expected = Arrays.asList(16, 14, 10, 8, 7, 9, 3, 2, 4, 1); List<Integer> after = new ArrayList<Integer>(before.size()); for(Integer i: before) after.add(i); tester.buildMaxHeap(after, comp, after.size()); System.out.println("after: " + after); assertArrayEquals(expected.toArray(), after.toArray()); }