Data Structures
Lists, trees, heaps and hash tables, implemented from scratch and graded against a test suite.
Contents
How data is arranged in memory, what each arrangement makes cheap, and how to pick one on purpose. Starts from what a data structure is and ends with the reasoning to choose between them.
How to think about data structures
What a data structure is, what computer memory actually looks like, and how to judge whether something is cheap or expensive without a stopwatch. Everything later in the course leans on this section, so it takes its time.
- 7 min
What a data structure actually is
A way of arranging things, plus a promise about what that arrangement makes easy.
- 9 min
The four things you ever do to a collection
Access, search, insert and delete: the questions to ask about every structure in this course.
- 10 min
What computer memory actually looks like
Numbered boxes in a very long row, and why the numbering is the whole trick.
- 7 min
Why the layout decides the cost
Two ways to store the same five numbers, and what each one charges to reach an item.
- 7 min
What it costs to add and remove an item
Insertion and deletion flip the comparison the other way, and the pointers charge rent in memory.
- 6 min
The rule a structure promises to keep
Most structures are a layout plus a rule, and maintaining the rule is where the cost lives.
- 8 min
Counting steps instead of seconds
Why a stopwatch is the wrong tool for understanding a structure, and what to count instead.
- 9 min
How work grows when the data grows
Four patterns of growth, with real numbers, and why the distance between them is enormous.
- 12 min
The halving game, and what a logarithm is
Why throwing away half of what is left at each step makes even enormous collections small, and what that is worth when sorting.
- 8 min
Big O, read out loud
Attaching the standard names and notation to patterns you already understand.
- 8 min
Worst case and average case
The same operation has several honest costs, and it matters which one is being quoted.
- 8 min
Amortised cost, and why it is honest
How an occasional expensive operation can still leave every operation cheap on average.
- 8 min
When counting steps misleads you
Three situations where the cost on paper is not the cost you get, and what to do about it.
Section quiz
Arrays
Opens once you finish How to think about data structures, including its quiz.
Linked lists
Opens once you finish Arrays, including its quiz.
Stacks and queues
Opens once you finish Linked lists, including its quiz.
Hash tables
Opens once you finish Stacks and queues, including its quiz.
Trees
Opens once you finish Hash tables, including its quiz.
Heaps and priority queues
Opens once you finish Trees, including its quiz.
Graphs
Opens once you finish Heaps and priority queues, including its quiz.
Choosing a structure
Opens once you finish Graphs, including its quiz.
Data Structures unit exam
Opens once every section is finished and every quiz is passed.