Quicksort superiority over Heap Sort

后端 未结 5 482
花落未央
花落未央 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 00:54

    Average-case complexity, and the fact that you can take simple steps to minimize the risk of worst-case complexity in Quicksort (e.g. select the pivot as a median of three elements rather than a single selected position).

提交回复
热议问题