Recap · Eight Structures, One Decision Table
Ten lessons done—all eight ways of organizing laid bare. This page adds nothing new. One job only: put them on the same table so later you can name the structure the moment you see the scenario. Scan the decision table, then play the picker and quick quiz to check whether you can really review AI-written code.
One structure per row: a one-line motto, its brightest strength, its sorest weakness, its real form in the AI world, and which lesson covered it. Watch for the “Weakness” column—the cost of picking wrong is all written there.
| Structure | One-line motto | Strength | Weakness | Its real form in AI | Source |
|---|---|---|---|---|---|
| 📚Array | Sit in a row, find by index | Direct by position; fast append at the end | Insert / delete in the middle shifts everyone | message list: every line you chat with the AI lives here | Lesson 2 |
| 🥞Stack | Last in, first out | Undo, backtrack, reverse the path | You can only touch the top one | Cmd+Z, function calls, Agent subtasks; runaway recursion → “stack overflow” | Lesson 3 |
| 🚶Queue | First in, first out | Fair line; peak shaving as a buffer | No cutting; can’t grab the middle | Task queues, message queues: an Agent’s work gets done in line | Lesson 4 |
| 🗃Hash table | Compute the slot, one-step direct hit | Lookup / dedupe unreasonably fast | No order; costs extra memory | Set / dict, session lookup, cache keys, corpus dedupe | Lesson 5 |
| 💾Cache | Don’t recompute what you’ve already done | Saves time and money | When to invalidate is the hardest call | KV Cache, semantic cache, browser cache, CDN—the invisible discount on your bill | Lesson 6 |
| 🌳TreeVariant: Trie (prefix tree) | Branch layer by layer; find by level | Naturally expresses nesting and hierarchy | Only parent–child; peer links don’t fit | File trees, JSON, AST; Trie is how Tokenizers cut words | Lessons 7 / 9 |
| 🕸Graph | Anything can link to anything | Expresses arbitrary many-to-many relations | Easy to cycle; traversal gets expensive | Knowledge graphs, social nets, multi-Agent DAG workflows | Lesson 8 |
| 🧭Vector | Meaning → coordinates; similar = nearby | Find things by “how alike” | Results are approximate; need a special index | Embedding + RAG retrieval: find nearest neighbors; HNSW makes hundred-million-scale instant | Lesson 10 |
💡 On phones, swipe the table left/right to see more
Memorizing the table doesn’t count—picking does. Eight real scenarios below: decide in your head first, then tap a card to check. Finish all eight for a surprise.
Checked 0 / 8 scenarios
Six either/or questions, each from a key judgment in the ten lessons. Tap for instant feedback—watch for the “why” in the explanation; that’s what you say out loud when reviewing.
✅ What this chapter wants you to take away
- Data structure = a way of organizing: from lesson 1’s “find the key” to today, every structure is a variant of that metaphor
- Ask “how do I look it up” first: by position→array; by key→hash; by hierarchy→tree; by relation→graph; by similarity→vector
- Then “how do things enter and leave”: FIFO→queue; LIFO→stack
- Trading space for time is evergreen: extra buckets for hash tables, extra stored results for caches—what you buy is speed and a cheaper bill
- Your role is to review: you needn’t hand-write any structure, but you must spot them in AI’s code and ask that “why”