List of utility methods to do Array Heap Sort
heapSort();"use strict"; var log=function(msg){console.log(msg);}; var alert=function(msg){log(msg);}; var arr = [3,6,7,5,3,6,2,9,1,5,33,-12,0,-122,-Infinity, 125, 33, 55, 77]; Array.prototype.heapSort = function () { arr = this; function _chunk(list) { var chunks = []; for(var i=0; i<list.length; i++) { ... | |
heapSort()Array.prototype.heapSort = function() { if (this.length < 2) { return this; } else { this.heapify(); this.unheapify(); return this; | |
heapSort()Array.prototype.heapSort = function() { var unsortedArray = this; class BinaryHeap { constructor() { this.content = []; push(elementToAdd) { this.content.push(elementToAdd); this.bubbleUp(this.content.length - 1); ... |