
File:Merge-sort-example-300px.gif · Wikimedia Commons · See Wikimedia Commons
merge sort
Sign in to saveAlso known as mergesort, MergeSort
worst-case optimal stable divide and conquer comparison sorting algorithm
In the Vinony graph
Within Vinony's link graph, merge sort is referenced by 124 other articles, and connects out to time complexity, Best, worst and average case and The Art of Computer Programming.
It is catalogued under topics including Comparison sorts, Divide-and-conquer algorithms and Stable sorts.
Its subject is documented across 48 Wikipedia language editions.
Key facts
- Class
- Sorting algorithm
- Data structure
- Array
- Worst case performance
- O ( n log n ) {\displaystyle O(n\log n)}
- Best case performance
- Ω ( n log n ) {\displaystyle \Omega (n\log n)} typical, Ω ( n ) {\displaystyle \Omega (n)} natural variant
- Average performance
- Θ ( n log n ) {\displaystyle \Theta (n\log n)}
- Worst case space complexity
- O ( n ) {\displaystyle O(n)} total with O ( n ) {\displaystyle O(n)} auxiliary, O ( 1 ) {\displaystyle O(1)} auxiliary with linked lists
via Wikipedia infobox
Wikidata facts
- Instance of
- divide-and-conquer algorithm
- Subclass of
- sorting algorithm
- Image
- Merge sort algorithm diagram.svg
Show 7 more facts
- discoverer or inventor
- John von Neumann
- Stack Exchange tag
- stackoverflow.com/tags/mergesort
- uses
- merge algorithm
- Commons category
- Merge sort
- derivative work
- Timsort
- time of discovery or invention
- 1945-00-00
- maintained by WikiProject
- WikiProject Mathematics
via Wikidata · CC0
~36 min read
Encyclopedic overview
In computer science, merge sort (also commonly spelled as mergesort or merge-sort) is an efficient and general purpose comparison-based sorting algorithm. Most implementations of merge sort are stable, which means that the relative order of equal elements is the same between the input and output. Merge sort is a divide-and-conquer algorithm that was invented by John von Neumann in 1945. A detailed description and analysis of bottom-up merge sort appeared in a report by Goldstine and von Neumann as early as 1948.
Algorithm
Excerpted from Wikipedia’s “merge sort” article, available under the CC BY-SA 4.0 licence.