摘要: 二分插入排序思路先在有序区通过二分查找的方法找到移动元素的起始位置,然后通过这个起始位置将后面所有的元素后移。二分插入排序实现Function.prototype.method = function(name, func){ this.prototype[name] = func; return this;};Array.method('bInsertSort', function(){ var len = this.length, i, j, tmp, low, high, mid; for(i=1; i=high+1; j--){ ... 阅读全文
posted @ 2013-10-08 23:49 JChen___ 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 插入排序思路从第二个元素开始和它前面的元素进行比较,如果比前面的元素小,那么前面的元素向后移动,否则就将此元素插入到相应的位置。插入排序实现Function.prototype.method = function(name, func){ this.prototype[name] = func; return this;};Array.method('insertSort', function(){ var len = this.length, i, j, tmp; for(i=1; i=0 && tmp < this[j]){ th... 阅读全文
posted @ 2013-10-08 23:39 JChen___ 阅读(240) 评论(0) 推荐(0) 编辑