HeapUtils { public static void buildMaxHeap(int[] data) { for (int i = data.length/2; i >= 0; i--) { maxHeapify(data, i); } }  static void buildMaxHeap(int[] data); static void maxHeapify(int[] data, int index); static void maxHeapify(int[] data, int index, int heapSize); static int getParent(int leafIndex);  }
@Test public void testBuildHeap() { int[] testData = {16, 4, 10, 14, 7, 9, 3, 2, 8, 1}; int[] expectedData = {16, 14, 10, 8, 7, 9, 3, 2, 4, 1}; HeapUtils.buildMaxHeap(testData); for (int i = 0; i < testData.length; i++) { Assert.assertTrue(testData[i] == expectedData[i]); } }