01Chapter 1: What counts as input sizeThis chapter assumes you can read a loop and a conditional, index into an array or list, and add up simple sums such as 1 + 2 + ... + n. It also assumes you know what an algorithm is: a fixed procedure that turns an input into an output.2 min read
02Chapter 2: Counting basic operations instead of secondsThis chapter assumes you can read Python loops and conditionals, index into lists, and add up simple sums such as 1 + 2 + ... + n. It covers the cost model: the rule for deciding what we count when we measure an algorithm.2 min read
03Chapter 3: Running time as a function of nThis chapter assumes you can read Python loops, index lists, and sum series such as 1 + 2 + ... + n. It builds on two earlier ideas: input size and counting basic operations.2 min read
04Chapter 4: Why inputs of the same size can cost different amountsThis chapter assumes you can read Python loops, index into lists, and add up sums like 1 + 2 + ... + n. It also assumes you already count basic operations as a function of input size n. Here we look at what that function leaves out.2 min read
05Chapter 5: Best case: the cheapest inputThis chapter assumes you can read Python loops, index into lists, and add simple sums like 1 + 2 + ... + n. It also assumes you know that running time is counted as basic operations, written as a function of input size n.2 min read
06Chapter 6: Worst case: the most expensive inputThis chapter assumes you can read Python loops, index lists, and sum series such as 1 + 2 + ... + n. It also assumes you know that running time is counted in basic operations as a function of input size n.2 min read
07Chapter 7: Assumptions about which inputs are likelyThis chapter assumes you can read Python loops, index lists, and sum series such as 1 + 2 + ... + n. It also assumes you know that the best and worst case are the cheapest and most expensive inputs of a given size.2 min read
08Chapter 8: Average case: cost over a distribution of inputsThis chapter assumes you can read short Python loops and sum simple series like 1 + 2 + ... + n. It also assumes you know that best and worst case are the cheapest and most expensive inputs of a given size.2 min read
09Chapter 9: Computing the average as an expected valueThis chapter assumes you can read short Python programs and sum series such as 1 + 2 + ... + n. It also assumes you know that the average case is a cost taken over a distribution of inputs.2 min read
10Chapter 10: Worked example: linear searchThis chapter assumes you can read Python loops, index into a list, and sum 1 + 2 + ... + n. It applies the best, worst, and average case definitions to one algorithm.2 min read
11Chapter 11: Worked example: insertion sortThis chapter assumes you know loops, list indexing, and sums like 1 + 2 + ... + n. It also assumes you have seen the best, worst, and average case defined, and have worked through linear search. Here we apply the same method to a sorting algorithm.2 min read
12Chapter 12: Big-O, Omega, and Theta in briefThis chapter assumes you can read a running-time function such as T(n) = 3n + 2 and that you know best, worst, and average case. Asymptotic notation describes how a function grows as n gets large. It ignores constant factors and small terms.2 min read
13Chapter 13: A case is not a bound: avoiding a common confusionThis chapter assumes you know how to count basic operations. It also assumes you have seen best, worst, and average case counts for linear search and insertion sort. Big-O, Omega, and Theta are used here only at the level of "upper, lower, and tight bound on a growth rate."2 min read
14Chapter 14: Choosing which case to rely onThis chapter assumes you can count basic operations, you know the definitions of best, worst, and average case, and you have seen linear search and insertion sort analyzed. Here you decide which case to use for a given requirement.2 min read
16Chapter 16: Worked example: quicksortThis chapter assumes you know the best, worst, and average case definitions from earlier chapters, the linear search and insertion sort examples, and how recursion works. Here we apply those ideas to quicksort and add one new factor: random choices made by the algorithm itself.2 min read
17Chapter 17: Average case compared with amortized costThis chapter assumes you know best, worst, and average case analysis, and can read simple Python and sums. It separates two ideas that both produce a "typical" cost but rest on different guarantees.2 min read