Nodejs Utililty Methods Array Heap

List of utility methods to do Array Heap

Description

The list of methods to do Array Heap are organized into topic(s).

Method

heapify()
Array.prototype.heapify = function(){
    var len = this.length,
        i = Math.floor(len/2);
    while(i >= 0){
        this.sift(i--);
    return this;
function heapSort(arr){
...
heapify()
Array.prototype.heapify = function() {
  this.forEach(function(num, index){
    if (index != 0) {
      var childPos = index;
      while (childPos > 0) {
        var parentPos = this.parentPos(childPos);
        if (this[childPos] > this[parentPos]) {
          this.swap(childPos, parentPos);
          childPos = parentPos;
...