Tools
Compare two algorithms
Pick any two topics to compare time, space, stability, best uses, and trade-offs. Copy the result as a Markdown table, or copy the link to share this exact comparison.
| Property | Merge sort | Quicksort |
|---|---|---|
| Time complexity | Θ(n log n) best, average, and worst | Θ(n log n) average; Θ(n²) worst |
| Auxiliary space | O(n) for arrays; O(log n) stack | O(log n) average stack; O(n) worst |
| Stable | Yes | No |
| In place | No (arrays) | Yes |
| Best used for | Linked 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-offs | Predictable 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. |