"use strict"; myMain(); function myMain() { var nums= [21,32,-19,4,71,-3,17,0,8,11,-18,27,54,-101,-9,62]; var hh = makeNewHeap(); alert("new heap size: "+ hh.size()); alert("minimum item: "+hh.getMin()); // expect nothing to be there // now load a bunch of elements into the new heap // this is not the special "build" // this is simulating items coming to the be added over time, // one at a time for (var i=0; ithis.elts[c]) { temp=this.elts[c]; this.elts[c]=this.elts[n]; this.elts[n]=temp; n = c; } else { done=true; } } } }, isLeaf: function (n) { return ( this.LC(n)>this.last && this.RC(n)>this.last ); }, hasOnlyLC: function (n) { return ( this.RC(n)>this.last && this.LC(n)<=this.last ); } } return heap; }