Resource · Guide or article
Merge Sort
Merge sort as a stable divide and conquer algorithm, shown with a top-down recursive example.
Reviewed
Open the original: Merge Sort (opens the original site in a new tab)Add to a roadmap
Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.
Source content: English
Read this in other languages: 한국어, Português In computer science, merge sort (also commonly spelled mergesort) is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945. An example of merge sort. First divide the list into the smallest unit (1 element), then compare each element with the adjacent list to sort and merge the two adjacent lists. Finally all the elements are sorted and merged.
PrepKit overview
PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.
- Suited to
- The source does not state a level
- Format
- Reference
What it covers
- Split to single elements, then merge adjacent lists.
- Diagram of the recursion on seven integers.
- Complexity table: n log(n) in all cases, memory n, stable.
How to use it
PrepKit study advice, not a claim made by the source.
Code top-down merge sort, trace it on the seven-value example, and explain where the n memory goes.
Scope and limitations
Brief; no bottom-up variant or exercises. Links to Wikipedia and YouTube. Korean and Portuguese versions are linked.
Access and format
English README on GitHub (MIT-licensed trekhleb/javascript-algorithms), free.
Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88
Evidence behind this overview
- src/algorithms/sorting/merge-sort/README.md
Pages that include this
Get the PrepKit newsletter
Optional. You don't need it to use PrepKit.