Hanno's non-recursion method
(I am really sorry, because 9CBS can be limited, it is divided into 4 parts, let you trouble. - I use the table with the table, causing the number of HTML code to increase, although it doesn't seem long, but actually Quite length.)
It seems that this problem is to recursion. If you want to use the stack to disassemble the recursive reached the form of elimination recursive, you are still using recursive ideas, so he is essentially a recursive algorithm. Our shabow is talking about "what situation uses recursive", in "3. The solution of the problem is recursive", "Some problems can only be solved by recursive ways, a typical example It is Hanno Tag. "
But I firmly believe that if a problem can be solved by a problem - recursive is actually an analytical method, it can break the problem into the same problem of -1 scale and move a plate. If this is decomposed, it will give a solution, final decomposition Go to the disk, the problem is solved - then I should also be able to solve the synthesis method, which is to determine how to move from the current state, rather than reverse. This is an simulation of the actual work process. Imagine if we let us move the plate, we will definitely do not use it to think about how to move now - as long as 8 plates, our "Work Stack" in our brain is going to overflow. - We must immediately decide how to move, instead of how many steps behind it know how to move. Below we look for this solution through the simulative thinking.
Suppose it will move the initial state of the 7 tray (7 because I have written a 1 ~ 6 result correct algorithm, and I found a condition for a condition in 7 times, I tried it myself), Our only choice is to move the 1st plate, but our problem is to move to C or move to C?
1
2
3
4
5
6
Seduce
A
B
C
Obviously, we must move the No. 7 plate to c. Before this, we must move the No. 6 to B. 5 will move to C, ... With this type, it will conclude (law 1): The current column The target column of the above tray should be, from the "need to move the tray" on the current column, alternately exchange the target column to the target column when it is. That is to say, if the current column is A, it is necessary to move M plates, from the target column of the mth disk from above, then the target column of the top on the uppermost tray is this: if (m% 2) target and The target of the mth plate is the same (C); the ELSE target and the target of the mth plate are different (b). Next, we need to consider that if it occurs, what should I do, as shown below: