01Chapter 1: Divide and Conquer: The Idea Behind QuicksortQuicksort is one of the most widely used sorting algorithms. Before looking at partitioning details, it helps to see the strategy it is built on, which is divide and conquer.2 min read
02Chapter 2: Partitioning an Array Around a PivotThis chapter assumes you can write Python functions, index into lists, and read Big-O notation. It defines the partition step that every version of quicksort relies on. The next chapter turns this definition into a working in-place algorithm.2 min read
03Chapter 3: The Lomuto Partition SchemeThis chapter assumes you can read Python and follow index-based loops over arrays. It also assumes you know what partitioning around a pivot means: elements smaller than the pivot go to its left, and the rest go to its right. Here you will implement one concrete way to do that, the Lomuto partition 3 min read
04Chapter 4: Putting It Together: Recursive QuicksortThis chapter assumes you can read Python, follow recursive calls on the call stack, and already know how the Lomuto partition from the previous chapter places a pivot at its final index. The task here is to combine that partition step with recursion to get a complete in-place sort.2 min read
05Chapter 5: In-Place but Not StableThis chapter assumes you can read the recursive Lomuto quicksort from the previous chapter, you know Big-O notation, and you know what a tuple key is in Python. It covers two properties people often mix up when choosing a sort: whether the sort needs extra memory, and whether it keeps equal elements2 min read
06Chapter 6: How Fast Is Quicksort? Best, Average, and Worst CaseThis chapter assumes you can read Big-O notation, follow a recurrence like T(n) = 2T(n/2) + n, and know the Lomuto quicksort from the earlier chapters. We count comparisons. Swaps never outnumber comparisons, so the comparison count sets the running time.2 min read
07Chapter 7: When Quicksort Goes QuadraticThis chapter assumes you have read the earlier chapters on the Lomuto partition scheme and the average-case analysis. You should also be comfortable with recursion and Big-O notation. Here we look at the inputs that push quicksort to O(n²) time, and at why those inputs are common in real data.3 min read
08Chapter 8: Choosing a Good PivotThis chapter assumes you know the Lomuto partition scheme, the recursive structure of quicksort, and why a lopsided split costs O(n²). Here we look at the pivot rules you can choose from and how to judge between them. Later chapters cover randomized pivots and median-of-three in detail.2 min read
09Chapter 9: Randomized QuicksortThis chapter assumes you know the Lomuto partition scheme, the recursive structure of quicksort, and why a pivot that is always the smallest or largest element leads to O(n²) time. You should also be comfortable with expected value in the basic probability sense.2 min read
10Chapter 10: Median-of-Three Pivot SelectionThis chapter assumes you already know the Lomuto partition scheme, the in-place recursive quicksort built on it, and why a fixed last-element pivot turns sorted input into an O(n²) case. Randomized quicksort, covered earlier, avoids that case by chance. Median-of-three avoids it with a cheap, determ2 min read
11Chapter 11: The Hoare Partition SchemeThis chapter assumes you already know the Lomuto partition scheme, the recursive quicksort that uses it, and Python's list indexing. It covers the partition scheme Tony Hoare published with quicksort in 1961. Hoare's version does fewer swaps than Lomuto's, but it returns a different kind of index, a2 min read
12Chapter 12: Three-Way Partitioning for Duplicate KeysThis chapter assumes you know the Lomuto partition scheme and the worst-case analysis from earlier chapters, and that you can follow recursive Python code.2 min read
13Chapter 13: Bounding Recursion DepthThis chapter assumes you know the Lomuto partition and recursive quicksort from earlier chapters. It also assumes you understand how the call stack grows with each recursive call, and that you know why sorted input makes a last-element pivot go quadratic.2 min read
14Chapter 14: Switching to Insertion Sort for Small SubarraysThis chapter assumes you know the in-place Lomuto quicksort from earlier chapters, how insertion sort works, and Big-O notation. Here you will add a size cutoff, so that quicksort hands small subarrays to insertion sort instead of recursing all the way down.2 min read
15Chapter 15: Introsort: Quicksort in Production LibrariesThis chapter assumes you already know the Lomuto partition, why quicksort can go quadratic, how recursing on the smaller side bounds stack depth, and why insertion sort is fast on small subarrays. Introsort combines these ideas into one algorithm. It keeps quicksort's speed on typical inputs and gua2 min read
16Chapter 16: Quickselect: Finding the k-th Smallest ElementThis chapter assumes you already know the Lomuto partition scheme and randomized pivot selection from earlier chapters. It also assumes you are comfortable with 0-based indexing and expected-case Big-O reasoning.2 min read