Hanoi
Hanoi is a mathematical problem formed according to a legend (about Hanoi):
There are three Poles a,b,c. A rod has N (n>1) perforated discs, the size of the disk from bottom to top in turn smaller. The following rules are required to move all discs to the C-bar:
Only one disk can be moved at a time;
The market cannot be stacked on a small plate.
Tip: The disc can be temporarily placed in the B-bar, or the disc removed from the A will be moved back to the A-bar, but must follow the above two rules.
Recursive Hanoi
Problem-Solving ideas: You can simplify the question to 2 plates, such as: A on two plates, B and C is empty. If you want to move all two plates of a to C, you need to go through the following steps:
1.A move a plate to B
2.A move a plate to C
3.B move a plate to C
Now that you have moved all the plates to C, you can actually think of the plates on the bottom of the chassis as a whole, which simplifies the 3-step process, and then uses the recursive repetition of the 3 steps to complete the displacement of all the plates.
Use a recursive Chen Hanno tower and print the changes and count steps for each step in real time.
"Data structure and algorithm" recursive Hanoi