disk 1 (smallest, on top)disk 2disk 3disk 4disk 5 (largest, at the bottom — when n = 5)the disk that just movedmove only the top disk of a rod · never place a larger disk on a smaller one
💬 Current step
💻 Lecture C++ code (whole program)
Yellow = current line. Recursion in three steps: ① n−1 disks from→aux ② disk n from→to ③ n−1 disks aux→to. The green box below is the cout terminal.
🥞 Recursion call stack hanoi(n, from, aux, to)
Speed
Shortcuts: Space play/pause · ←→ step · R reset · E result