Complexity
- Best: O(n log n)
- Average: O(n log n)
- Worst: O(n log n)
- Space: O(n)
Generate a random array and watch merge sort divide and conquer step by step.
Current: No operation yet
Generate an array to start sorting
Playback speed
Merge Sort recursively splits an array into smaller halves, sorts each half, and merges them into a fully ordered result. It is stable and guarantees predictable performance.
Merge sort is great when you want predictable O(n log n) runtime and stable sorting behavior.
Yes. Merge sort is stable because equal elements keep their relative order when merged correctly.
During merging, temporary arrays are used to combine sorted halves, which leads to O(n) extra space.