reesexu (徐文超 )- 2020-02-23 0 人
heapSort
// 挖坑法参考 https://blog.csdn.net/qq_36528114/article/details/78667034#commentBox
const partSort = (array, left, right) => {
    const pivot = array[right]
    while(left < right) {
        while(left < right && array[left] <= pivot) {
            left++
        }
        array[right] = array[left]
        while(left < right && array[right] >= pivot) {
            right--
        }
        array[left] = array[right]
    }
    array[left] = pivot
    return right
}

const quickSort = (array, left = 0, right = array.length - 1) => {
    if (left < right) {
        const pivotIndex = partSort(array, left, right)
        quickSort(array, left, pivotIndex - 1)
        quickSort(array, pivotIndex + 1, right)
    }
}

const arr = [3,44,38,5,47,15,36,26,27,2,46,4,19,50,48]
quickSort(arr)
console.log(arr)
reesexu (徐文超 )- 2020-02-21 0 人
quickSort
reesexu (徐文超 )- 2020-02-16 0 人
debounce&throttle
reesexu (徐文超 )- 2020-02-15 0 人
mergeSort
reesexu (徐文超 )- 2020-02-14 0 人
shellSort
reesexu (徐文超 )- 2020-02-13 0 人
insertionSort
没有了
1/2 下一页