Intermediate 25 min

Interactive Visualization

Watch merge sort work in real-time. The visualizer shows the divide and merge process.

Merge Sort Visualization

1x

What to Observe

As you watch the visualization, notice:

  1. Divide phase: Array is split into halves repeatedly
  2. Base case: Single elements are already sorted
  3. Merge phase: Sorted halves are merged back together
  4. Recursion: The process repeats at each level
  5. Final merge: All elements come together sorted

Understanding the Colors

  • Blue: Elements being divided
  • Green: Sorted portions
  • Orange/Red: Elements being merged
  • Purple: Final sorted array

Try Different Arrays

The visualizer shows how merge sort:

  • Always divides in the same way
  • Merges in a predictable pattern
  • Guarantees O(n log n) performance

What’s Next?

Now that you’ve seen it work, let’s implement merge sort in code.