merge sort


Definition: A sort algorithm that splits the items to be sorted into two groups, recursively sorts each group, and merges them into a final, sorted sequence. Run time is Θ(n log n).

Generalization (I am a kind of ...)

Specialization (... is a kind of me.)
k-way merge sort, balanced k-way merge sort, polyphase merge sort.

Aggregate child (... is a part of or used in me.)
divide and conquer.

See also external sort, bitonic sort, strand sort.

Note: There seem to be some references to linear-time in-place merging; look for papers by Geffert, Katajainen & Pasanen.

Author: PEB


(C) that needs list merge (C) or array merge (C), (Pascal) that needs list merge (Pascal) or array merge (Pascal); (Java); Demo and code of in-place and double merge sort (Java); Worst-case behavior annotated for real time (WOOP/ADA), including bibliography. Siegfried Sielaff's description and code of an in-place, stable variant he calls Swap Sort (C) (click the British flag for an English translation). Other implementations may be available through the Stony Brook Algorithm Repository, Sorting. Alexander Georgiev's merge sort (Java) implemented as part of a linked-list package. Includes a parallel merge sort, too.

More information

animation (Java). Comparison of quicksort, heapsort, and merge sort on modern processors.

Merge sort illustrated through a Transylvanian-saxon (German) folk dance. Created at Sapientia University.

Go to the Dictionary of Algorithms and Data Structures home page.

If you have suggestions, corrections, or comments, please get in touch with Paul Black.

Entry modified 8 November 2016.
HTML page formatted Fri Feb 23 10:06:08 2018.

Cite this as:
Paul E. Black, "merge sort", in Dictionary of Algorithms and Data Structures [online], Vreda Pieterse and Paul E. Black, eds. 8 November 2016. (accessed TODAY) Available from: