Algorithm dossier
- Category: Game AI
- Worst-case complexity: O(2ⁿ)
- Approach: Recursive
- Data structure: No DS
- First formalised: 1880s
Why this snippet is Tower of Hanoi
Why Tower of Hanoi. The recurrence T(n) = 2·T(n-1) + 1 solves to 2ⁿ - 1. The three-rod, n-disc puzzle becomes "move n-1 from source via destination to spare, move the bottom disc, then move n-1 from spare via source to destination." Two recursive calls bracketing a single output append — the unmistakable shape. Teaching value. First nontrivial recursive algorithm most CS students see; the prototype for divide-and-conquer.
How to read a redacted algorithm
Algodle strips identifier names so the snippet has to be read for its shape: the control flow, the data structures it manipulates, the order in which it visits its input. Loops with two pointers crawling toward each other are usually search or partition. A recursion that splits its input in half and recurses on both halves is divide-and-conquer. A priority queue plus graph traversal is almost certainly Dijkstra, Prim, or A*. Six hint columns — category, complexity, approach, data structure, era — let you triangulate even when the snippet itself is opaque.