Update: Jeremy Kubica's third book of humorous explanations of computer science, The CS Detective, is now available!
Details on all books here.
For a full list of stories organized by topic, see below. You can also start from the first story or jump to the most recent story. Also see the FAQ for more info about the site itself.Details on all books here.
Computational Fairy Tales includes over 70 stories that cover a range of different computer science concepts from introductory programming, to high level CS concepts, to data structures and algorithms, to computational complexity, to practical programming tips. Different stories are written in different levels of detail and abstraction (and thus might be better matches for different audiences; also see Stories by Level or the FAQ). Some representative examples are:
- Caching and the Library of Alexandria [High level CS Concepts]
- The Importance of Comments: A Baker's Tale [Practical Programming Tips]
- Swapping Array Values and the Swimmy Friends Pet Store [Basic Programming]
- Hunting Dragons with Binary Search [Algorithms]
- Malloc, Free, and the Mall of New Athens [Memory Allocation]
Algorithms:
- The Ant and the Grasshopper: A Fable of Algorithms [algorithms]
- Hunting Dragons with Binary Search [binary search]
- Binary Searching for Cinderella [binary search]
- Breadth First Search and the Pig Thief [breadth first search]
- Panicked Depth First Search [depth first search]
- Sorting Algorithms:
- Why Tailors Use Insertion Sort [insertion sort]
- Bullies, Bubble Sort, and Soccer Tickets [bubble sort]
- Merge Sort and Lines of Kindergartners [merge sort]
- Sorting During the Flu Outbreak: The Reality of Sorting Small Data Sets [sorting]
- Minimax Search and the Oracle of Old Toronto [minimax]
- Ann's Visit to G'Raph [graph algorithms] - See "Graphs" section below
Data Structures:
- Linked Lists, Kindergarten, and Ocean Voyages [linked lists]
- Arrays, Linked Listed, and Zed's Coffee Shop [arrays / linked lists]
- Choose Your Own Adventure Novels Are Not Linked Lists [linked lists]
- Stacks, Queues, Priority Queues, and the Prince's Complaint Line [stacks / queues / priority queues]
- President of the Heap [heaps]
- Binary Search Trees and Speck the Spider [binary search trees]
- Amoebas Have Boring Family Trees [binary trees]
- Ushers, Peanut Venders, and Matrix Indices [matrices]
- Ann's Visit to G'Raph [graphs] - See "Graphs" section below
Graphs (Data Structures and Algorithms):
- The City of G'Raph: Part 1 in Ann's Visit to G'Raph [intro to graphs]
- Directed Graphs, Bridges, and the Mayor's Office: Part 2 of Ann's Visit to G'Raph [directed vs undirected edges]
- Bridge Weights: Part 3 of Ann's Visit to G'Raph [weighted edges]
- Dijkstra's on Scooters: Part 4 of Ann's Visit to G'Raph [Dijkstra's algorithm]
- A Disagreement Over Data Structures: Part 5 of Ann's Visit to G'Raph [adjacency matrices / adjacency lists]
- The Traveling Salesman's Problem: Part 6 of Ann's Visit to G'Raph [traveling salesman problem]
- Panicked Depth First Search: Part 7 of Ann's Visit to G'Raph [depth first search]
- Minimum Spanning Trees, Prim's Algorithm, and Bridge Upgrades: Part 8 of Ann's Visit to G'Raph [minimum spanning trees / Prim's algorithm]
- The Game of Hamiltonian Paths: Part 9 of Ann's Visit to G'Raph [hamiltonian paths]
- Connected Components and the Birthday Sign [connected components]
Basic Programming:
- The Marvelous IF-ELSE Life of the King's Turtle (IF-ELSE)
- Learning IF-ELSE the Hard Way (IF-ELSE)
- Variables, IF Statements, and Magic Boots (Variables)
- Switch/Case and the Palace Guards (Switch/Case)
- Loops and Making Horseshoes (While Loops / For Loops)
- While Loops and Dizziness (While Loops)
- Singing with Loops (While loops / For loops)
- Functions and Sailing
- Boolean Logic:
- Goldilocks and the Two Boolean Bears
- The Town of Bool: Part 1 of Ann's encounter with the Booleans
- The Gates of XOR: Part 2 of Ann's encounter with the Booleans
- The Valley of NAND and NOR: Part 3 of Ann's encounter with the Booleans
- Fun with Boolean Statements
- Strings:
- Peter's Address Stamp (of Strings as Arrays of Characters): Part 1 of Peter and the Postal Service
- Incorrectly Delivered Mail and Comparing Strings: Part 2 of Peter and the Postal Service
- The Hamming Distance Option: Part 3 of Peter and the Postal Service
- Swapping Array Values and the Swimmy Friends Pet Store [array swapping]
Memory / Pointers:
- Pointers and Walk-In Closets
- Computer Memory and Making Dinner
- Malloc, Free, and the Mall of New Athens
Practical Programming:
- The Importance of (Variable) Names [variable names]
- Names for Ingredients (and Variables) [variable names]
- The Importance of Comments: A Tale of The Baker's Apprentice [comments]
- The Curse of Excessive Commenting [comments]
- Variable Initialization in Busy Kitchens
- The Incident at the North Gate (or Why == Is Not =)
- Const and Library Books [C++]
- Data Validation, Marcus, and the Minstrel of Cheese: Part 1 of Marcus and the Cursed Cheese [data validation]
- The Importance of Unit Testing Magical Spells [unit tests]
- The Fairy's Sandbox [sandboxes]
- Version Control in Magic Spell Development [version control]
- Integer Overflow and 00000 Customers Served [integer overflow]
- Recursion, Overhead, and Computational Graffiti [recursion]
- Enums and Hair Colors [enums]
- The Importance of Design in Five Course Meals [software design]
Computational Complexity and Big-O Notation:
Object-Oriented Programming:
- Objects, Encapsulation, and Cheese Factories: Part 2 of Marcus and the Cursed Cheese
- Classes of Cheese: Part 3 of Marcus and the Cursed Cheese
- Inheritance in Cheese and Magic Spells: Part 4 of Marcus and the Cursed Cheese
- Classes, Inheritance, and the Three Little Pigs
Other Computer Science Concepts:
- The Tortoise, the Hare, and 50000 Ants [parallel algorithms]
- Unhappy Magic Flowers and Binary [binary]
- Using Binary to Warn of Snow Beasts [binary]
- Encodings for Tic-Tac-Toe [encodings]
- Programming Languages, Compilers, and Pigeons [compilers]
- Caching and the Librarian of Alexandria [caching]
- Packets, Supply Chains, and the Road to Alexandria [packets]
- Check Pointing Checkers [check pointing / fault tolerance]
- Noop: The Man Who Stood In Lines (But Did Not Do Anything Else) [No-op]
- Pixels, Peacocks, and the Governor's Turtle Fountain [pixels]
- Bog Dragons Do Not Support Multithreading [threads]