摘要
尽管递归算法具有结构简练、清晰、可读性强、正确性容易得到证明等优点,但递归算法在执行过程中会耗费太多时间和空间.为了追求算法的时空效率,特别是使用不支持递归的程序语言的情况下,必须将递归算法转化为非递归算法,问题才能得到有效解决.为此,给出了递归算法转化为非递归算法的一般方法,并以Hanoi塔问题、二叉树的中序遍历问题为例进行了详细地分析.
A recursive algorithm's structure is simple, clear and readable, moreover, its correctness is easy to cerlify. But a recursive algorithm will cost too much time and space during the process, we should transform the recursive altorithm into a nonrecursive algorithm for time and space efficiency, especially when we implement it with a kind of recursionunsupported programming language. For this, the general rule of transforming a recursive algorithm into a nonrecursive algorithm is discussed in this paper. Two examples, hanoi tower problem and traversing binary tree,are discussed in detail.
出处
《四川师范大学学报(自然科学版)》
CAS
CSCD
2003年第2期209-212,共4页
Journal of Sichuan Normal University(Natural Science)
关键词
递归
递归算法
非递归算法
Recursion
Recursive algorithm
Non-recursive algorithm