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

Posted springxxxx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了算法——希尔排序与快速排序相关的知识,希望对你有一定的参考价值。

      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)
        }
      }   

 

以上是关于算法——希尔排序与快速排序的主要内容,如果未能解决你的问题,请参考以下文章