What sort algorithm provides the best worst-case performance?

后端 未结 16 2105
[愿得一人]
[愿得一人] 2020-12-15 14:44

What is the fastest known sort algorithm for absolute worst case? I don\'t care about best case and am assuming a gigantic data set if that even matters.

16条回答
  •  旧巷少年郎
    2020-12-15 14:52

    For the man with limitless budget

    Facetious but correct: Sorting networks trade space (in real hardware terms) for better than O(n log n) sorting!

    Without resorting to such hardware (which is unlikely to be available) you have a lower bound for the best comparison sorts of O(n log n)

    O(n log n) worst case performance (no particular order)

    • Binary Tree Sort
    • Merge Sort
    • Heap Sort
    • Smooth Sort
    • Intro Sort

    Beating the n log n

    If your data is amenable to it you can beat the n log n restriction but instead care about the number of bits in the input data as well

    Radix and Bucket are probably the best known examples of this. Without more information about your particular requirements it is not fruitful to consider these in more depth.

提交回复
热议问题