Created
January 28, 2018 04:09
-
-
Save keehyun2/283004828a8c396c686a195a742464f7 to your computer and use it in GitHub Desktop.
buildHeap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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