Comparison With Other Sort Algorithms
Although heapsort has the same time bounds as merge sort, it requires only Θ(1) auxiliary space instead of merge sort's Θ(n), and is often faster in practical implementations. On typical modern architectures, efficient quicksort implementations generally outperform mergesort for sorting RAM-based arrays. On the other hand, merge sort is a stable sort, parallelizes better, and is more efficient at handling slow-to-access sequential media. Merge sort is often the best choice for sorting a linked list: in this situation it is relatively easy to implement a merge sort in such a way that it requires only Θ(1) extra space, and the slow random-access performance of a linked list makes some other algorithms (such as quicksort) perform poorly, and others (such as heapsort) completely impossible.
As of Perl 5.8, merge sort is its default sorting algorithm (it was quicksort in previous versions of Perl). In Java, the Arrays.sort methods use merge sort or a tuned quicksort depending on the datatypes and for implementation efficiency switch to insertion sort when fewer than seven array elements are being sorted. Python uses timsort, another tuned hybrid of merge sort and insertion sort, that has become the standard sort algorithm for Java SE 7, and on the Android platform.
Read more about this topic: Merge Sort
Famous quotes containing the words comparison with, comparison and/or sort:
“Clay answered the petition by declaring that while he looked on the institution of slavery as an evil, it was nothing in comparison with the far greater evil which would inevitably flow from a sudden and indiscriminate emancipation.”
—State of Indiana, U.S. public relief program (1935-1943)
“Clay answered the petition by declaring that while he looked on the institution of slavery as an evil, it was nothing in comparison with the far greater evil which would inevitably flow from a sudden and indiscriminate emancipation.”
—State of Indiana, U.S. public relief program (1935-1943)
“There is no object so foul that intense light will not make beautiful. And the stimulus it affords to the sense, and a sort of infinitude which it hath, like space and time, make all matter gay. Even the corpse has its own beauty.”
—Ralph Waldo Emerson (18031882)