Frontier and Future Development of Information Technology in Medicine and Education pp 1527-1531 | Cite as
Data Structure Teaching Practice: Discussion on Non-recursive Algorithms for the Depth-First Traversal of a Binary Tree
Abstract
The recursive algorithms for depth-first traversal of a binary tree are widely expatiated upon in data structure textbooks. There are three depth-first traversal sequences for a binary tree, preorder, inorder, and postorder traversal sequences. My literature survey indicates the most references present the depth-first traversals algorithms as recursive ones. Some literatures have introduced the non-recursive algorithms only for one of these three traversal sequences of a binary tree. In this paper a general non-recursive algorithm for the depth-first traversal of a binary tree is proposed. This general non-recursive algorithm can visit every nodes of a binary tree in preorder, inorder, or postorder traversal sequence. The algorithm analysis shows that this new algorithm is efficient and easy to understand. The implementation of this new algorithm was done in C and the complete algorithm was tested.
Keywords
Binary tree Depth-first traversal Non-recursiveReferences
- 1.Gilberg RF, Forouzan BA (1998) Data Structures: A Pseudocode A pproach with C. PWS Publishing Company, BostonGoogle Scholar
- 2.Yan Wei-min and Wu Wei-min Wu (2007) Data Structure (in Chinese). Tsinghua University press, BeijingGoogle Scholar
- 3.AI-Rawi A, Lansari A, and Bouslama F (2003) “A new non-recursive algorithm for binary search tree traversal”. In: Proceedings of the 2003 10th IEEE international conference on electronics, circuits and systems, ICECS 2003, vol 2, pp 770–773Google Scholar
- 4.Liu Zhong-hua and Zhang Ying-chao (2010) Depth-first Search and Non-recursive Algorithm. Sci & Technol Inf (in Chinese) 25:160–161Google Scholar
- 5.Weiss MA (1993) Data Structures and Algorithm Analysis in C++. The Benjamin/Cummings Publishing Company, Redwood CityGoogle Scholar
- 6.Wang M (2011) Non-recursive simulation on the recursive algorithm of binary tree reverting to its corresponding forest in intelligent materials. Appl Mech and Mater 63–64:222–225Google Scholar
- 7.Vinu V Das (2010) A new non-recursive algorithm for reconstructing a binary tree from its traversals. In: Proceedings of the 2010 2nd international conference on advances in recent technologies in communication and computing, ARTCom 2010, pp 261–263Google Scholar