AlgoScope

Merge Sort

AlgorithmintermediateSorting

Merge two sorted runs by always taking the smaller front value.

Decision · step 4 of 36Merge Sort: Eight values
merging 0-11✓011422384357667write

1 is smaller than 5, so 1 is written to index 0.

Open in the player →or start at step 4

What you will see

MERGE neighbouring runs -> the smaller head is written down -> runs double in width each pass.

How merge sort works →

Cost

BestO(n log n)
AverageO(n log n)
WorstO(n log n)
SpaceO(n)

Properties

  • ✓ comparison based
  • ✓ stable
  • × in place
  • × adaptive
  • × online

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, compare two runs.

Screen readers: Cells announce index, value and state (comparing, swapped, sorted); each step announces the comparison outcome and any move.

Reduced motion: Swaps become value crossfades with outline flashes; sorted-region growth is a static span change.

Taught by the same lesson

Merge Sort covers these too, in the same run.