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

BestO(n log n)
AverageO(n log n)
WorstO(n log n)
SpaceO(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.

Advertise

Part of GOAT Lab — 26 free, browser-based science, engineering and developer tools. No sign-up.