Course C — Data structures for agents

Unit 12: Data structures for agents

Self-paced · about 60 minutes · Course C, one unit

Learning objectives

Lessons

Lesson What you leave with
1. Big-O, then measure The five shapes of cost with a course example each, and a timeit figure for a scan against a dict lookup
2. list, dict, set Dedupe with a set, index by doc id with a dict, key a chunk by a tuple; why a list cannot be a key
3. Stack, queue, recursion The agent loop as a deque of pending tool calls with a budget, and a recursive walk that stops
4. Trees and graphs BFS, DFS and topological order over the storefront fixture; derive order is a topological sort

Checking your answers

Every exercise in notebook.ipynb has the same shape: context, numbered instructions, a starter that runs as shipped and gives a wrong or incomplete answer (marked <------ EDIT THIS LINE), the expected output, and a check(...) cell that prints ✅ or ❌ with the fix named. The last cell, review("w12"), is the scorecard.

The checks here judge behaviour, not text. The timing check refuses a pair of numbers a scan-versus-lookup measurement cannot produce. The dedupe check runs your function on two lists whose first-seen orders differ. The walk runs on a node whose children contain itself, under a deadline. The order check hands you the fixture's edges reversed, then a cycle.

Working with a coding assistant: give it the exercise's context and instructions, let it edit the marked lines, then run the check cell yourself. You read the verdict, not the assistant. solutions/notebook.ipynb is the reference; open it after the check, not before.

Slides

slides.md is a Marp deck. Read it as Markdown, or render it:

npx @marp-team/marp-cli slides.md -o slides.pdf

Previous: Databases, APIs, and third-party servers · Next: Configure the assistant and the repository instructions