| | |
Summary: PREPRINT. Information Processing Letters, 34(1):2125, 1990.
Construction of a Tree from its Traversals in
Optimal Time and Space \Lambda
Arne Andersson Svante Carlsson
Department of Computer Science
Lund University
Lund, Sweden
Abstract
Given the preorder traversal of a tree together with some additional
structure information, the tree can be constructed in linear time with
a simple algorithm. The additional information may be the inorder or
postorder traversal. In one case, the binary search tree, no additional
information is required. We also show how to transform the construc
tion algorithm into a nonrecursive algorithm requiring only constant
space.
Keywords: Analysis of algorithms, data structures, binary tree, multiway
tree, binary search tree, tree traversal, tree construction
1 Introduction
The problem of constructing a binary tree from its preorder and inorder
traversals is well known. Lately Burgdorff et. al. [2] gave a nonrecursive
|