🎬

Sorting Visualizer

Watch sorting algorithms in action. Compare how different approaches tackle the same data — see the comparisons, swaps, and patterns that make each algorithm unique.

Related OCaml files: mergesort.ml, sorting.ml

Merge Sort

Divide-and-conquer: split array in half, recursively sort each half, merge results. Stable and predictable.

Best: O(n log n) Average: O(n log n) Worst: O(n log n) Space: O(n)
60
Comparisons
0
Array Accesses
0
Time
0.0s

How to Use

  1. Pick an algorithm and array size
  2. Click Start to begin the animation
  3. Watch the bars: red = comparing, yellow = pivot, green = sorted
  4. Adjust speed mid-animation, or pause to study a step
  5. Try the same array with different algorithms to compare!