MergeSort Time Complexity (Big-O)
MergeSort runs in O(n log n) in best, average, and worst case, using O(n) extra memory. It is a stable divide-and-conquer sort that recursively merges sorted halves in linear time.
Open the interactive DevRef Hub tool →Key facts
| Best | O(n log n) |
|---|---|
| Average | O(n log n) |
| Worst | O(n log n) |
| Space | O(n) |
Frequently asked questions
What is the time complexity of MergeSort?
O(n log n) in all cases — best, average, and worst.
Is MergeSort stable?
Yes, MergeSort is a stable sort but needs O(n) extra memory.
Related pages
Big-O of MergeSort is part of DevRef Hub on GOAT Lab — a free reference you can use without signing up, and it works offline. Open the tool above for any custom value.
Part of GOAT Lab — 26 free, browser-based science, engineering and developer tools. No sign-up.