Javascript Array insertationSort()
Array.prototype.insertationSort = function() { this.procedures=[]//from w ww . j a v a2 s . c o m var compare = 0 var exchange = 0 var comparet = this.length * this.length / 4 var exchanget = comparet for (var i = 1; i < this.length; i++) { for (var j = i; j > 0; j--) { compare++ if (this.less(j, j - 1)) { this.exch(j, j - 1) exchange++ } else { break } } // virtualize(this, i) } console.log(comparet + '????' + exchanget) console.log(compare + '????' + exchange) }