Merge Sort
intermediateDivides the array in half, sorts each half, then merges — guaranteed O(n log n) and stable.
PHASE 1 — SPLITTING into smaller pieces
38
27
43
3
9
82
Left array
Right array
Merged / sorted
We start with [38, 27, 43, 3, 9, 82]. Merge Sort splits the array into halves, sorts each half, then merges them back.
1 / 45