Why does Haskell use mergesort instead of quicksort?

前端 未结 6 926
执念已碎
执念已碎 2021-01-31 01:38

In Wikibooks\' Haskell, there is the following claim:

Data.List offers a sort function for sorting lists. It does not use quicksort; rather, it uses an ef

6条回答
  •  天命终不由人
    2021-01-31 01:58

    Short answer:

    Quicksort is advantageous for arrays (in-place, fast, but not worst-case optimal). Mergesort for linked lists (fast, worst-case optimal, stable, simple).

    Quicksort is slow for lists, Mergesort is not in-place for arrays.

提交回复
热议问题