SW StudyWalks

Computer Science  /  CS 0145  ·  Procedure · 60–90 seconds

Merge Sort, Run to the Floor

Video not yet published
to the StudyWalks catalog
State

Merge sort sorts a list by dividing it into halves until every sublist is one element long — already sorted by definition — then merging adjacent sorted sublists back into larger sorted sublists, at a total cost in O(N log N).

Show

Take eight shuffled cards. Divide: eight becomes two fours, becomes four twos, becomes eight ones — and eight single cards are eight sorted piles. Now merge, always by comparing the two front cards and taking the smaller. Eight piles merge into four sorted pairs; four pairs merge into two sorted fours; two fours merge into one sorted eight. Three rounds of merging — because eight halves to one in three steps — and each round handles all eight cards once. That is the whole cost story: the number of rounds is the halving count, log of N, and every round touches N cards, which is where N log N comes from. The comparisons did all the work, and no card ever needed a number on its face — heavier-or-lighter was enough.

Watch for

The merge step is where the sorting actually happens; the dividing only sets the table.