Quicksort slower than Mergesort?

后端 未结 15 1146
名媛妹妹
名媛妹妹 2021-02-07 02:01

I was working on implementing a quicksort yesterday, and then I ran it, expecting a faster runtime than the Mergesort (which I had also implemented). I ran the two, and while th

15条回答
  •  孤街浪徒
    2021-02-07 02:38

    If you implement heap sort as the base sorting algorithm in quick sorts worst case scenario, you achieve a theta(n log n) algorithm.

    If you don't need stable sorting, and don't sort a linked list, I think that would be the fastest you could go.

    Merge sort

提交回复
热议问题