Skip to content

Instantly share code, notes, and snippets.

@keehyun2
Created January 28, 2018 04:09
Show Gist options
  • Save keehyun2/283004828a8c396c686a195a742464f7 to your computer and use it in GitHub Desktop.
Save keehyun2/283004828a8c396c686a195a742464f7 to your computer and use it in GitHub Desktop.
buildHeap
/**
* heapify 함수를 활용하여 Heap 을 구축합니다.
* @param arr
* @param nodeIndex
* @param heapSize
*/
void buildHeap(int[] arr, int nodeIndex, int heapSize) {
if(nodeIndex >= heapSize/2) return;
buildHeap(arr, 2 * nodeIndex + 1, heapSize); // buildHeap- left subTree
buildHeap(arr, 2 * nodeIndex + 2, heapSize); // buildHeap- right subTree
heapify(arr, nodeIndex, heapSize);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment