Merge sort compared with Quicksort
PropertyMerge sortQuicksort
Time complexityΘ(n log n) best, average, and worstΘ(n log n) average; Θ(n²) worst
Auxiliary spaceO(n) for arrays; O(log n) stackO(log n) average stack; O(n) worst
StableYesNo
In placeNo (arrays)Yes
Best used forLinked lists, external sorting, and any time you need a stable sort or a guaranteed O(n log n).In-memory arrays of primitives where average speed and cache behavior matter.
Trade-offsPredictable running time, but the extra buffer costs memory and cache locality.Usually the fastest in practice, but a bad pivot sequence gives quadratic time. Randomized or median-of-three pivots make that unlikely.

Keyboard shortcuts

/
Search topics
?
Show this list of shortcuts
r
Open the revision sheet
b
Save or unsave the focused card, or the topic you are reading
l
Mark the focused card, or the topic you are reading, as learned
Space Left arrow Right arrow
In the visualizer: play or pause, step back, step forward
1 to 4 Enter
In the quiz: pick an answer, then go to the next question
Escape
Close this list