# An optimal parallel algorithm to reconstruct a binary tree from its traversals

## Abstract

We consider the following problem. For a binary tree T=(V,E) where V={1, 2,...,n}, given its inorder traversal and either its preorder traversal or it postorder traversal, reconstruct the binary tree. We present a new parallel algorithm for this problem. Our algorithm requires O(*n*) space. The main idea of our algorithm is to reduce the reconstruction process to parallel merging. With the best results for parallel merging, our algorithm can be implemented in O(logn) time using O(*n*/log*n*) processors on the EREW PRAM, or in O(loglogn) time using O(*n*/log log*n*) processors on the CREW PRAM. Consequently, an ordered tree can be reconstructed from its preorder and postorder traversals. Our results improve the best previous results for this problem in literature either in cost or in the model of computation.

## Keywords

Algorithms Binary trees Ordered trees PRAM Parallel algorithms Traversals## Preview

Unable to display preview. Download preview PDF.

## References

- [1]A. Anderson, S. Carlsson, “Construction of a tree from its traversals in optimal time and space,”
*Information Processing Letters*, 34 (1990) pp. 21–25Google Scholar - [2]R. J. Anderson, E. W. Mayr and M. K. Warmuth, “Parallel approximation algorithms for bin packing,”
*Information and Computation*, 82, October, 1989, pp. 262–277.Google Scholar - [3]O. Berkman, Z. Galil, B. Schieber and U. Vishkin, “Highly Parallelizable Problems,” in Proceedings of the
*IEEE Symposium on Foundation of Computer Science*, 1989.Google Scholar - [4]G. H. Chen, M. S. Yu and L. T. Liu, “Two algorithms for constructing a binary tree from its traversals,”
*Information Processing Letters*, 28 (1988) pp. 297–299.Google Scholar - [5]R. Cole, “Parallel Merge sort,” in
*Proceedings of the 27th Annual IEEE Symposium on the Foundations of Computer Science*, 1986, pp. 511–516.Google Scholar - [6]R. Cole and U. Vishkin, “Approximate and exact parallel scheduling with applications to list, tree and graph,”
*Proc. 27th Annual Symp. on Foundations of Computer Science*, 1986, pp. 487–491.Google Scholar - [7]C. Kruskal, “Searching, merging and sorting in parallel computation,”
*IEEE Transactions on Computers*C-32, 10 (October), pp.942–946.Google Scholar - [8]D. E. Knuth, The Art of Computer Programming, Vol. 1, Fundamental Algorithms, Second Edition, Addison-Wesley, Reading, Mass., 1973.Google Scholar
- [9]F. Springsteel, I. Stojmenovic, “Parallel general prefix computations with geometric, algebraic and other applications,” In Proceedings of International Conference on Fundamentals of Computation Theory, Szeged, Hungary, August 1989, 424–433, Springer-Verlag.Google Scholar
- [10]R. E. Tarjan and U. Vishkin, “Finding biconnected and computing tree functions in logarithmic parallel time,” in
*Proceedings of the 25th Annual Symposium on Foundations of Computer Science, 1984*, pp. 12–22.Google Scholar - [11]U. Vishkin, “Synchronous parallel computation,” a Survey,
*TR 71*, Dept. of Computer Science, Courant Institute, NYU, 1983.Google Scholar