Package com. arithmetic; // heapsort is a sort algorithm designed by using the data structure of heap. A heap is a structure similar to a fully binary tree. // It satisfies the heap nature at the same time. That is, the key value or index of a subnode is always smaller than or greater than its parent node. Public class test_wzs013 {Private Static int [] Sort = new int [] {10, 3, 5, 7, 9, 1, 4, 2, 6, 8 }; public static void main (string [] ARGs) {buildmaxheapify (SORT); heapsort (SORT); print (SORT);} Private Static void buildmaxheapify (INT [] data) {// create the maximum heap only when no child node exists. Int startindex = getparentindex (data. length-1); // create the maximum heap from the end. The heap is correct for (INT I = startindex; I> = 0; I --) {maxheapify (data, data. len Required, I) ;}/ ***** create the maximum heap ** @ Param data * @ Param heapsize * You need to create the maximum heap size, which is generally used in sort, because the maximum value is placed at the end, the end is no longer classified as the maximum heap * @ Param Index * the location where the maximum heap needs to be created */Private Static void maxheapify (INT [] data, int heapsize, int index) {// compare the current vertex with the Left and Right subnodes: int left = getchildleftindex (INDEX); int right = getchildrightindex (INDEX); int largest = index; if (left