Quiz Entry - updated: 2026.12.02
Merge-sort and quick-sort are both divide-and-conquer. How do they differ in where they do their work?
Merge-sort splits blindly in the middle and does all its comparisons when merging: easy split, hard join. Quick-sort does all its comparisons when partitioning around the pivot and joins by concatenating: hard split, easy join.
| merge-sort | quick-sort | |
|---|---|---|
| Divide | cut in the middle, no comparisons | partition: compare every element with the pivot |
| Conquer | merge, up to $n - 1$ comparisons | concatenate $L$, $E$, $G$, no comparisons |
| Tree shape | always balanced, height $\lceil \log_2 n \rceil$ | depends on the pivots, height between $\log_2 n$ and $n - 1$ |
| Time | $O(n \log n)$ for every input | $O(n \log n)$ expected, $O(n^2)$ worst case |
| Extra memory | $O(n)$ buffer for merging | in-place version: only the recursion stack |
| Stable | yes, if ties go to the left half | no |
The two are mirror images. Quick-sort compares on the way down the recursion, before its recursive calls; merge-sort compares on the way back up, after them. Merge-sort's blind cut guarantees a balanced tree, and it pays for that at the join. Quick-sort's join is free, but its tree is only as balanced as its pivots are good.
Go deeper:
Quicksort: relation to other algorithms — quick-sort compared with merge-sort, heap-sort and their hybrids.