| | |
Summary: PREPRINT. Computer Journal, 33(5):471472, 1990.
A Note on the Expected Behaviour of Binary
Tree Traversals
Arne Andersson
Department of Computer Science
Lund University
Lund, Sweden
Abstract
Brinck and Foo [1, 2] have analyzed tree traversal algorithms using
threads and stack. In this note we show that, contrary to the results
in the two referred papers, a preorder traversal is performed faster with
a stack than with threads, in terms of pointer assignments. Moreover,
the preorderstack traversal is faster than any of the other standard
traversals analyzed in [1] and [2].
1 Introduction
It is well known that adding threads to a binary tree makes it possible to
traverse the tree in preorder, inorder or postorder without using any stack.
Although the asymptotic complexity are the same for the stack and thread
algorithms the time constant may differ. A comparison of the two methods
has been made by Brinck and Foo [1, 2]. They present efficient algorithms for
|