
/**
* author Akalius Kung 2008-2-9
**/
public class HeapSort {
private int heapLen;
private int[] sort(int[] array){
heapLen=array.length;
buildHeap(array); // init the heap
for(int i=heapLen-1;i>0;i--){ // swap root and last node, up to down
swap(array,i,0);
heapLen--;
heapify(array,0); // reheapify the root node from 0 to n-1
}
return array;
}
private void buildHeap(...