Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Merge sort
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==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''). On typical modern architectures, efficient [[quicksort]] implementations generally outperform merge sort for sorting RAM-based arrays.<ref name=":2">{{Cite journal |last1=Oladipupo |first1=Esau Taiwo |last2=Abikoye |first2=Oluwakemi Christianah |accessdate=2024-01-20 |date=2020 |title=Comparison of quicksort and mergesort |url=https://www.sciencedirect.com/science/article/pii/S1877050920312667/pdf |journal=Third International Conference on Computing and Network Communications (CoCoNet 2019) |volume=2020 |issue=2020 |pages=9 |via=Elsevier Science Direct}}</ref> Quicksorts are preferred when the data size to be sorted is lesser, since the space complexity for quicksort is O(log ''n''), it helps in utilizing cache locality better than merge sort (with space complexity O(n)).<ref name=":2" /> On the other hand, merge sort is a stable sort 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).<ref>{{cite web| url=https://perldoc.perl.org/5.8.8/sort.html| title=Sort β Perl 5 version 8.8 documentation| access-date=2020-08-23}}</ref> In [[Java platform|Java]], the [https://docs.oracle.com/javase/9/docs/api/java/util/Arrays.html#sort-java.lang.Object:A- 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.<ref>{{cite web |url= https://hg.openjdk.java.net/jdk/jdk/file/9c3fe09f69bc/src/java.base/share/classes/java/util/Arrays.java#l1331 |work=OpenJDK |author=coleenp |date=22 Feb 2019 |title=src/java.base/share/classes/java/util/Arrays.java @ 53904:9c3fe09f69bc}}</ref> The [[Linux]] kernel uses merge sort for its linked lists.<ref>[https://github.com/torvalds/linux/blob/master/lib/list_sort.c linux kernel /lib/list_sort.c]</ref> [[Timsort]], a tuned hybrid of merge sort and insertion sort is used in variety of software platforms and languages including the Java and Android platforms<ref>{{cite web |author=University of Liverpool |title=Computer scientists improve Python sorting function |website=Tech Xplore |date=2022-12-12 |url=https://techxplore.com/news/2022-12-scientists-python-function.html |access-date=2024-05-08}}</ref> and is used by [[Python (programming language)|Python]] since version 2.3; since version 3.11, Timsort's merge policy was updated to [[Powersort]].<ref>{{cite web |last=James |first=Mike |title=Python Now Uses Powersort |website=i-programmer.info |date=2022-12-21 |url=https://www.i-programmer.info/news/216-python/15954-python-now-uses-powersort.html |access-date=2024-05-08}}</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Merge sort
(section)
Add topic