Recursively splits the array, then merges sorted halves back together. Stable, O(n log n).
Up to 8 numbers — each level shows the array split in half, then merged back sorted.
Recursively splits the array, then merges sorted halves back together. Stable, O(n log n).
Time complexity: O(n log n). Space complexity: O(n).
Core idea — Recursively split the array in half until each piece is a single element, then merge halves back together in order.
What each pass accomplishes — Each merge fuses two already-sorted sub-arrays into one bigger sorted sub-array. Working up the tree, the sorted runs double in size every level until the whole array is one sorted run.
Use the interactive visualizer above to run Merge Sort on your own input and watch every comparison, swap, and operation animate step by step — pause, scrub, or replay at any speed.