Java版堆排序

Java版堆排序
/** * 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(...

Java版堆排序

Java版堆排序
/** * 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(i...
Copyright © 浩然东方 保留所有权利.   Theme  Ality 07032740

用户登录