01Chapter 1: Measuring cost by input size, not by secondsTwo programs can solve the same problem, and one can be far cheaper than the other. This chapter sets up the way we compare them. Instead of timing a run, we count the work an algorithm does as a function of the size of its input. The rest of the tutorial builds on that idea.3 min read
02Chapter 2: How functions grow: comparing n, n squared, and 2 to the nThis chapter assumes you can write loops and recursive functions, read basic algebra with exponents, and use lists. Logarithms help but are not required. The previous chapter counted operations as a function of input size n. Here you compare how those counts grow.3 min read
03Chapter 3: What Big O means: an upper bound for large nThis chapter assumes you can read simple Python, know what a function of n is, and are comfortable with basic algebra. Earlier chapters showed that we count steps as a function of input size n and compare how those counts grow. Here we turn that idea into a precise definition.3 min read
04Chapter 4: Simplifying: drop constants and lower-order termsThis chapter assumes you can read basic Python loops and functions, and that you are comfortable with exponents. You should also know the formal definition of Big O from the previous chapter: f(n) is O(g(n)) if there are constants c > 0 and n0 such that f(n) ≤ c·g(n) for all n ≥ n0.3 min read
05Chapter 5: The common complexity classes from O(1) to O(n!)This chapter assumes you can read Python loops and recursion, know what an array is, and are comfortable with exponents. A rough grasp of logarithms helps. Here, log n means the number of times you can halve n before reaching 1. Earlier chapters showed how to drop constants and lower-order terms. Th2 min read
06Chapter 6: Reading complexity from loops and nested loopsThis chapter assumes you can write loops and functions in Python and know that Big O drops constants and lower-order terms. Here you will apply those rules to real code.2 min read
07Chapter 7: Big Omega and Big Theta: lower and tight boundsThis chapter assumes you know the formal definition of Big O and how to drop constants and lower-order terms. Big O only says a function grows no faster than some bound. Two companion notations cover the other directions.3 min read
08Chapter 8: Best, worst, and average caseThis chapter assumes you can read loops and nested loops for their cost, and that you know Big O is an upper bound and Big Omega is a lower bound. Here we separate two ideas that beginners often merge: the kind of bound (O, Ω, Θ) and the kind of input (best, worst, average).3 min read
09Chapter 9: Analyzing recursion with recurrence relationsThis chapter assumes you can read recursive functions, know how loops map to Big O, and are comfortable with exponents and basic logarithms. Loops can be counted directly. A recursive function calls itself, so its cost is defined in terms of its own cost on smaller inputs. A recurrence relation is a3 min read
10Chapter 10: Solving recurrences: unrolling and the Master TheoremThis chapter assumes you can write a recurrence for a recursive function, such as T(n) = 2T(n/2) + n for merge sort. It also assumes you are comfortable with exponents and logarithms. Here you learn to turn a recurrence into a Big O bound.3 min read
11Chapter 11: Space complexity and the call stackThis chapter assumes you can read Big O expressions, simplify them, and analyze loops and simple recursion. It applies the same tools to memory instead of time.3 min read
13Chapter 13: Complexity of common data structure operationsThis chapter assumes you can read Big O notation, know the difference between worst-case, average-case, and amortized cost, and use Python lists, dicts, and sets.2 min read
14Chapter 14: When Big O is not enough: constants, caches, and small inputsThis chapter assumes you can read the complexity classes from O(1) to O(n!), simplify cost expressions, and analyze loops and recursion. Big O answers one question: how does cost grow as n becomes large? It does not tell you which of two programs is faster on the input you have. Three things sit out2 min read