VisualAlgo

Mini Algorithm Playground • Merge Sort

Generate a random array and watch merge sort divide and conquer step by step.

Current: No operation yet

Merge Sort View

O(n log n)

Generate an array to start sorting

Default
Sorted

Controls

Playback speed

Merge Sort in Plain Language

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.

Complexity

  • Best: O(n log n)
  • Average: O(n log n)
  • Worst: O(n log n)
  • Space: O(n)

How It Works

  • Divide-and-conquer strategy
  • Recursive splitting into halves
  • Stable merging of sorted subarrays
  • Predictable O(n log n) runtime

Merge Sort FAQ

What is merge sort best used for?

Merge sort is great when you want predictable O(n log n) runtime and stable sorting behavior.

Is merge sort stable?

Yes. Merge sort is stable because equal elements keep their relative order when merged correctly.

Why does merge sort use extra memory?

During merging, temporary arrays are used to combine sorted halves, which leads to O(n) extra space.