Abstract

AbstractThe 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.KeywordsBinary treeDepth-first traversalNon-recursive

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.