首页 > 编程语言 > 详细

算法——希尔排序与快速排序

时间:2021-06-22 15:19:00      阅读:14      评论:0      收藏:0      [点我收藏+]
      ArrayList.prototype.shellSort = function () {
        let length = this.array.length
        let gap = Math.floor(length / 2)
        while (gap >= 1) {
          for (let i = gap; i < length; i++) {
            let temp = this.array[i]
            let j = i;
            while (temp < this.array[j - gap] && j > gap - 1) {
              this.array[j] = this.array[j - gap]
              j -= gap
            }
            this.array[j] = temp
          }
          gap = Math.floor(gap / 2)
        }
      }   

 

算法——希尔排序与快速排序

原文:https://www.cnblogs.com/creationMarvel/p/14918082.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!