Non-Recursive Algorithm Based on Down-Up Record Method for Hanoi Tower
-
Graphical Abstract
-
Abstract
The code of classical recursion algorithm for Hanoi tower problem is simple,but the time complexity is O(2n) and the code is difficult to understand.Understanding recursive idea of Hanoi tower problem and constructing a tree model based on the function,two objectives of the functions parameters and the execution result are analyzed carefully.Then the relationship between them is obtained and used to design a new down-up non-recursive algorithm.This algorithm here records the moving paths of n plates (n=1,2,…),which could be applied to get the moving result of n+1 plates directly.The experimental results show that the corresponding code is very easy to read,and its time complexity is only O(n),which is further practice and study for the non-recursive research of Hanoi tower problem.
-
-