Overview
Merge Sort divides the input into smaller halves, sorts each half, and merges two sorted sequences by repeatedly taking the smaller front item.
Sorts a list by recursively sorting halves and merging the sorted results.
Compact metadata for implementation and discovery.
Merge Sort divides the input into smaller halves, sorts each half, and merges two sorted sequences by repeatedly taking the smaller front item.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n log n)
Average
O(n log n)
Worst
O(n log n)
Space
O(n)
Show the list splitting into halves and merging back in sorted order.
Merge sort's predictable runtime makes it useful when worst-case quicksort behavior is unacceptable.
What each reference supports for this entry.
Textbook support for Merge Sort invariants, recurrences, relaxation rules, or asymptotic analysis.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Sorting · Foundation
Merge Sort guarantees n log n time and stable merging, while Quick Sort partitions in place.
Compare with thisSorting · Core
Natural Merge Sort uses Merge Sort as a subroutine, representation, or supporting idea while detecting existing sorted runs and merging them.
Compare with thisSorting · Core
TimSort merges detected runs using merge-sort-style stable merging.
Compare with thisSorting · Extended
External sorting commonly creates sorted runs and merges them with merge-sort-style passes.
Compare with thisParallel merge sort extends merge sort by distributing recursive work.
Merge Sort guarantees n log n time and stable merging, while Quick Sort partitions in place.