Tale & Theory

Books / Learning comic

Data Structures & Algorithms Through Stories

Theme: Computing & AI

This book is organized into twelve complete chapters. Its coverage follows a festival rush at Switchyard Delivery that turns data structures and algorithms into practical decisions. Mira, a new engineer, works with dispatcher Jonah and mentor Lin to organize parcels, preserve order, find routes and choose valuable deliveries. Their story connects precise contracts and loop invariants to arrays, linked lists, stacks, queues, hash tables, search trees, heaps and graphs. Sorting, binary search, recursion, shortest paths, greedy proofs and dynamic programming emerge from concrete problems rather than isolated definitions. Exact diagrams and worked traces keep values, positions and assumptions visible. Boundary cases, counterexamples and answered retrieval questions challenge plausible mistakes. The recurring question is what a method guarantees, what it costs and which workload makes it useful.

Start reading →View in the interactive library
Data Structures & Algorithms Through Stories cover

About this book

This book is organized into twelve complete chapters. The story starts at Switchyard Delivery, where a festival rush exposes improvised software. Mira joins dispatcher Jonah and mentor Lin to turn questions into computational problems. A cart named Pip supplies humor while the team learns to distinguish an idea from a correct algorithm with stated assumptions. The journey begins with an earliest deadline scan. A contract settles empty input, equal deadlines, returned positions and mutation. A complete trace develops a loop invariant and separates initialization, preservation and termination. Exact comparison counts introduce asymptotic upper, lower and tight bounds, different cases, quadratic pair enumeration and auxiliary space. Tests target boundaries and side effects without pretending that examples prove everything. Changing manifests motivate arrays and linked lists. Address arithmetic explains indexed access; careful shifts preserve sequence order during insertion and removal. Logical length differs from backing capacity. Geometric growth gives an aggregate copying bound, while resizing still makes individual calls expensive. Linked nodes reveal traversal costs, reference identity, safe assignment order and endpoint cases. Stack and queue interfaces then constrain access through undo histories, pickup order and circular buffers. Tracking keys introduce maps, collisions, full key equality, load factor and rehashing. Expected efficiency is tied to explicit hashing assumptions rather than guaranteed by a label. Binary search develops shrinking intervals and duplicate boundaries on sorted data. Recursive calls expose base cases, progress and stack space. Sorting compares stable ordering, permutation preservation, insertion, merging, partitioning and the domain assumptions that allow alternatives to comparison sorting. Ordered lookup leads to binary search trees, where the ordering invariant does not guarantee a balanced shape. Search paths, deletion, rotations and height explain the tradeoff. Priority queues instead maintain a heap whose root exposes the next urgent item without sorting every waiting parcel. Array indices, upward and downward repair, bottom up construction and arrival counters make the representation and tie policy concrete. The city becomes a graph of depots and roads. Adjacency representations support breadth first and depth first traversal, parent reconstruction, components, cycle detection and dependency ordering. Weighted routes require a different promise: Dijkstra requires nonnegative edge weights for finalization. A counterexample explains why that condition matters, while Bellman Ford introduces negative edges, unreachable vertices and the meaning of reachable negative cycles. Greedy choices face proof rather than intuition. Compatible loading intervals support an exchange argument, while coin systems and indivisible parcels expose tempting rules that fail. Dynamic programming defines states, transitions, base cases and dependency order before filling a table. Memoization, tabulation, reconstruction and rolling storage connect repeated subproblems to implementable solutions. Capacity bounded parcel selection also explains why a numeric bound can produce pseudo polynomial complexity. Every chapter combines original illustrated conversations with exact vector diagrams, worked examples, misconceptions and answered checks. Companion notes follow physical PDF pages and distinguish visible dialogue from additional teaching. The closing method is practical: identify the required behavior, trace a small case, justify correctness, count the relevant resources, test fragile assumptions and choose a structure for the whole workload.

Published chapters

  1. 01 - The Parcel That Exposed the Plan
  2. 02 - Shelves That Grow and Chains That Bend
  3. 03 - The Door and the Undo Button
  4. 04 - The Address With Too Many Neighbors
  5. 05 - Half the Search and a Smaller Promise
  6. 06 - The Manifest Must Keep Its Promises
  7. 07 - A Tree That Leaned Too Far
  8. 08 - The Next Parcel Is Not the Whole Order
  9. 09 - The City Becomes a Graph
  10. 10 - The Shortest Road Needs a Condition
  11. 11 - A Good First Choice Needs a Proof
  12. 12 - Remember the Work and Choose the Tool