Skip to content

Instantly share code, notes, and snippets.

@vaidehijoshi
Created July 13, 2017 14:57
Show Gist options
  • Save vaidehijoshi/c70622e47743abcd0c986024c3da8e77 to your computer and use it in GitHub Desktop.
Save vaidehijoshi/c70622e47743abcd0c986024c3da8e77 to your computer and use it in GitHub Desktop.
function buildMaxHeap(array) {
var i;
i = array.length / 2 - 1;
i = Math.floor(i);
// Build a max heap out of
// all array elements passed in.
while (i >= 0) {
heapify(array, i, array.length);
i -= 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment