Data Structures & Algorithms

Mergesort, Quicksort, and Recurrences

4:32

Plays from YouTube. Watch on YouTube

Why does mergesort guarantee n log n time while quicksort can degrade to quadratic work?

Meet divide-and-conquer sorting through mergesort and quicksort.

We start by splitting a sequence, sorting smaller pieces and merging two ordered halves.

From there, we prove merge correctness, derive the mergesort recurrence and trace quicksort's pivot partitioning.

Finally, we compare balanced and worst-case partitions, stability, memory use and consistent comparison functions.

The big idea: recursive sorting performance depends on how problems are divided and how answers are combined.

Sorting algorithms explained visually, one concept at a time.