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
static void sort(int arr[]) | |
{ | |
// to sort the elements | |
int n = arr.length; | |
// build max heap | |
for(int i = n/2 - 1 ;i>=0; i--) | |
{ | |
// i=n/2-1 as it will give us the left and right child nodes at the first level of the heap | |
heapify(arr,n,i); | |
} |
NewerOlder