Quicksort superiority over Heap Sort

后端 未结 5 483
花落未央
花落未央 2020-11-29 00:07

Heap Sort has a worst case complexity of O(nlogn) while Quicksort has O(n^2). But emperical evidences say quicksort is superior. Why is that?

5条回答
  •  独厮守ぢ
    2020-11-29 01:12

    Here's a couple explanations:

    http://www.cs.auckland.ac.nz/software/AlgAnim/qsort3.html

    http://users.aims.ac.za/~mackay/sorting/sorting.html

    Essentially, even though the worst case for quick sort is O(n^2) it on average will perform better. :-)

提交回复
热议问题