01Chapter 1: How a program uses memory: stack and heapThis chapter assumes you can read basic Python, know what a list and a function call are, and have seen Big O notation for time complexity. No earlier knowledge of memory layout is needed.3 min read
02Chapter 2: What space complexity measuresSpace complexity describes how much memory an algorithm needs as its input grows. It is the memory counterpart of time complexity. Time complexity counts steps. Space complexity counts memory cells, such as variables, list slots, and stack frames.3 min read
03Chapter 3: Writing space usage in Big O notationThis chapter assumes you know basic Python, lists and dictionaries, and introductory Big O for time. Here you will learn to turn "how much memory does this use?" into a Big O statement.2 min read
04Chapter 4: Input space versus auxiliary spaceThis chapter assumes you can read Python, know Big O notation for time at an introductory level, and understand what space complexity measures. Here you will learn to separate the memory an algorithm is given from the memory it asks for.3 min read
05Chapter 5: Constant and linear space in loopsThis chapter assumes you can read Python, know what a list is, and understand Big O notation for time. It also assumes you know the difference between input space and auxiliary space from the previous chapter. Here you will learn to look at a loop and decide whether it uses O(1) or O(n) auxiliary sp3 min read
06Chapter 6: How much space common data structures takeThis chapter assumes you know Python lists, dictionaries and sets, and that you can read Big O notation. You should also know the difference between input space and auxiliary space. Here you will learn how much memory the common containers need as a function of the number of items they hold.2 min read
07Chapter 7: Recursion and the call stackRecursion costs memory even when a function creates no lists. This chapter assumes you know Big O for time, Python lists, and how a recursive function calls itself.2 min read
08Chapter 8: Hidden costs: slices, copies and string concatenationThis chapter assumes you can read Big O notation, know Python lists and strings, and have seen the difference between input space and auxiliary space. Some lines of code look cheap but allocate a whole new object. These hidden costs change the space complexity of a function, so you have to count the2 min read
09Chapter 9: In-place algorithmsThis chapter assumes you can read Big O notation, know how Python lists and recursion work, and have seen the difference between input space and auxiliary space. An in-place algorithm is one that transforms its input using only O(1) auxiliary space, apart from the input itself. It overwrites or rear3 min read
10Chapter 10: Analyzing the space of a function step by stepThis chapter assumes you know Big O notation for time, can read Python, and understand the difference between input space and auxiliary space. It also assumes you know how recursion uses the call stack. Here you combine those ideas into one repeatable procedure.3 min read
11Chapter 11: Trading space for time and time for spaceThis chapter assumes you know Big O for time, can read basic Python, and have seen auxiliary space and the call stack in earlier chapters. Here you will learn to treat memory and running time as two costs you can exchange, and to decide which one to spend.3 min read
12Chapter 12: Memoization and the space cost of dynamic programmingThis chapter assumes you know Big O notation for time, can read recursive Python, and have seen how recursion uses call stack space. Memoization speeds up a function by storing results it has already computed. That speed costs memory, and this chapter shows how much.3 min read
13Chapter 13: Streaming data with generatorsThis chapter assumes you know Python loops and lists, Big O notation, and the difference between input space and auxiliary space. A generator lets you process data one item at a time, so memory use stays constant no matter how much data flows through.2 min read
14Chapter 14: Auxiliary space of common sorting algorithmsThis chapter assumes you know Big O notation, the difference between input space and auxiliary space, and how recursion uses the call stack. Here we apply those ideas to sorting. Two algorithms with the same running time can differ a lot in the extra memory they need.2 min read
15Chapter 15: Measuring memory use in practiceThis chapter assumes you can read Big O notation, know the difference between input space and auxiliary space, and can write basic Python. An analytical estimate tells you how memory grows. A measurement tells you whether your estimate matches what the interpreter does. Use both.3 min read