Quicksort slower than Mergesort?

后端 未结 15 1149
名媛妹妹
名媛妹妹 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:59

    Were you datasets random enough? Were they partially sorted?

    That might affect the speed of the sort...

    Like for the QuickSort's partition(), you'd skip along if the numbers are in sorted order, until you find one that's not.

提交回复
热议问题