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

Full Text
Published version (Free)

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