SortingAnimated
Merge Sort
Split, sort halves, merge. Stable and predictable.
Time
O(n log n)
Extra space
O(n)
Use it for
Linked lists, external sorting, stability needed.
How it works
- Split the list in half, again and again, until each piece has one item.
- Merge two sorted pieces by repeatedly taking the smaller front item.
- Merging goes back up until one sorted list remains.
- Always O(n log n); uses extra memory for merging.
Watch it run
Loading animation…