Quick Sort vs Merge Sort
Same 220 values, same shuffle, same speed. Quick Sort finishes first and turns gold: 2,856 operations to 3,178.
The numbers
- Quick operations
- 2,856
- Merge operations
- 3,178
- Quick average
- n log n
- Merge average
- n log n
- Quick worst
- n²
- Merge worst
- n log n
Quick Sort
Quick Sort picks a pivot, splits the list into smaller and larger halves, and sorts each half the same way. More on Quick Sort.
Merge Sort
Merge Sort splits the list in half, sorts both halves, then merges the two sorted halves into one. More on Merge Sort.
FAQ
Which is faster, Quick Sort or Merge Sort?
On this shuffle of 220 values, Quick Sort needed 2,856 operations and Merge Sort needed 3,178, about 1.1× as many. On average Quick Sort is n log n and Merge Sort is n log n.
Which one is stable?
Merge Sort is stable; Quick Sort is not.
How is the race fair?
Both algorithms start from the same shuffle and run the same number of operations per frame. Every comparison, swap and write counts as one operation, so the one that needs fewer operations finishes first.