Abstract
We survey and classify the various algorithms for traversing binary trees in the three principal orders and the related two- and three-visit traversal orders. For each class of algorithms we determine which of the traversal orders may be effected by means ofloop-free traversal algorithms. Although, in general, these are multi-visit traversal orders, we indicate how the algorithms may be modified to yield loop-freesingle-visit traversal algorithms in “non-standard” orders. We also exhibit and discuss the close relationship between the various stack-based algorithms and the other classes of algorithms.
Similar content being viewed by others
References
E. N. Adams III,Another representation of binary tree traversal, Information Processing Lett. 2 (1973), 52–54.
K. Brinck and N. Y. Foo,Analysis of algorithms on threaded trees, Computer J. 24 (1981), 148–155.
W. A. Burkhard,Nonrecursive tree traversal algorithms, in Proceedings of the 7th Annual Princeton Conference on Information Sciences & Systems (1973), 403–405.
W. A. Burkhard,Nonrecursive traversals of trees, Computer J. 18 (1975), 227–230.
B. Dwyer,Simple algorithms for traversing a tree without an auxiliary stack, Information Processing Lett. 2 (1974), 143–145.
G. Ehrlich,Loopless algorithms for generating permutations, combinations, and other combinatorial configurations, J. ACM 20 (1973), 500–513.
T. I. Fenner and G. Loizou,A note on traversal algorithms for triply linked binary trees, BIT 21 (1981), 153–156.
E. Horowitz and S. Sahni,Fundamentals of Computer Algorithms, Computer Science Press Inc., Potomac, Maryland, (1978).
A. C. Kilgour,Generalized non-recursive traversal of binary trees, Software — Practice and Experience 11 (1981), 1299–1306.
D. E. Knuth,Fundamental Algorithms. The Art of Computer Programming, Vol. 1, 2nd edition, Addison-Wesley, Reading, Mass., (1973).
G. Lindstrom,Scanning list structures without stacks or tag bits, Information Processing Lett. 2 (1973), 47–51.
W. D. Maurer,An alternate characterization of preorder, inorder and postorder, ACM Sigplan Notices 16 (1981), 60–61.
J. M. Morris,Traversing binary trees simply and cheaply, Information Processing Lett. 9 (1979), 197–200.
A. J. Perlis and C. Thornton,Symbol manipulation by threaded lists, Comm. ACM 3 (1960), 195–204.
J. L. Pfaltz,Computer Data Structures, McGraw-Hill, New York, (1977).
E. M. Reingold, J. Nievergelt and N. Deo,Combinatorial Algorithms: Theory and Practice, Prentice-Hall, Englewood Cliffs, New Jersey, (1977).
J. M. Robson,An improved algorithm for traversing binary trees without auxiliary stack, Information Processing Lett. 2 (1973), 12–14.
H. Schorr and W. M. Waite,An efficient machine-independent procedure for garbage collection in various list structures, Comm. ACM 10 (1967), 501–506.
L. Siklóssy,Fast and read-only algorithms for traversing trees without an auxiliary stack, Information Processing Lett. 1 (1972), 149–152.
S. Soule,A note on the nonrecursive traversal of binary trees, Computer J. 20 (1977), 350–352.
T. A. Standish,Data Structure Techniques, Addison-Wesley, Reading, Mass., (1980).
W. A. Wulf, M. Shaw, P. N. Hilfinger and L. Flon,Fundamental Structures of Computer Science, Addison-Wesley, Reading, Mass., (1981).
Author information
Authors and Affiliations
Rights and permissions
About this article
Cite this article
Fenner, T.I., Loizou, G. Loop-free algorithms for traversing binary trees. BIT 24, 33–44 (1984). https://doi.org/10.1007/BF01934513
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF01934513