DAI Liping, HUANG Longjun, LIU Qinghua. Non-Recursive Algorithm Based on Down-Up Record Method for Hanoi Tower[J]. Experiment Science and Technology, 2016, 14(1): 51-54. DOI: 10.3969/j.issn.1672-4550.2016.01.016
Citation: DAI Liping, HUANG Longjun, LIU Qinghua. Non-Recursive Algorithm Based on Down-Up Record Method for Hanoi Tower[J]. Experiment Science and Technology, 2016, 14(1): 51-54. DOI: 10.3969/j.issn.1672-4550.2016.01.016

Non-Recursive Algorithm Based on Down-Up Record Method for Hanoi Tower

  • 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 functions 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.
  • loading

Catalog

    Turn off MathJax
    Article Contents

    /

    DownLoad:  Full-Size Img  PowerPoint
    Return
    Return