Lecture 30: Quicksort

11/4/2020

Backstory, Partitioning

Sorting So Far

Context for Quicksort's Invention

The Core Idea of Tony's Sort: Partitioning

Interview Question

Simplest (but not fastest) Answer: 3 Scan Approach

Quicksort

Partition Sort, a.k.a. Quicksort

Quicksort

Quicksort Runtime

Best Case: Pivot Always Lands in the Middle

Worst Case: Pivot Always Lands at Beginning of Array

Quicksort Performance

(Intuitive) Argument #1 for Average Runtime: 10% Case

(Intuitive) Argument #2: Quicksort is BST Sort

Empirical Quicksort Runtimes

Quicksort Performance

Sorting Summary (so far)

Avoiding the Quicksort Worst Case

Quicksort Performance

Avoiding the Worst Case