Abstract
Given the inorder and preorder traversal of a binary tree whose labels are all distinct, one can reconstruct the tree. This article examines two existing algorithms for rebuilding the tree in a functional framework, using existing theory on function inversion. We also present a new, although complicated, algorithm by trying another possibility not explored before.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Abramov, S.M., Glück, R.: The universal resolving algorithm: inverse computation in a functional language. Science of Computer Programming 43, 193–299 (2002)
Backhouse, R.C., Hoogendijk, P.F.: Elements of a relational theory of datatypes. In: Möller, B., Schuman, S., Partsch, H. (eds.) Formal Program Development. LNCS, vol. 755, pp. 7–42. Springer, Heidelberg (1993)
Bird, R.S., de Moor, O.: From dynamic programming to greedy algorithms. In: Möller, B., Schuman, S., Partsch, H. (eds.) Formal Program Development. LNCS, vol. 755, Springer, Heidelberg (1993)
Bird, R.S., de Moor, O.: Algebra of Programming. International Series in Computer Science. Prentice Hall, Englewood Cliffs (1997)
Chen, W., Udding, J.T.: Program inversion: more than fun! Science of Computer Programming 15, 1–13 (1990)
Dijkstra, E.W.: Program inversion. Technical Report EWD671, Eindhoven University of Technology (1978)
Gries, D., van de Snepscheut, J.L.: Inorder traversal of a binary tree and its inversion. In: Dijkstra, E.W. (ed.) Formal Development of Programs and Proofs, pp. 37–42. Addison Wesley, Reading (1990)
Harrison, P.G., Khoshnevisan, H.: On the synthesis of function inverses. Acta Informatica 29, 211–239 (1992)
Hinze, R.: Constructing tournament representations: An exercise in pointwise relational programming. In: Boiten, E.A., Möller, B. (eds.) MPC 2002. LNCS, vol. 2386, p. 131. Springer, Heidelberg (2002)
Knuth, D.E.: The Art of Computer Programming: Fundamental Algorithms, 3rd edn., vol. 1. Addison Wesley, Reading (1997)
de Moor, O., Gibbons, J.: Pointwise relational programming. In: Rus, T. (ed.) AMAST 2000. LNCS, vol. 1816, pp. 371–390. Springer, Heidelberg (2000)
Mu, S.-C.: A Calculational Approach to Program Inversion. PhD thesis, Oxford University Computing Laboratory (2003)
Mu, S.-C., Bird, R.S.: Inverting functions as folds. In: Boiten, E.A., Möller, B. (eds.) MPC 2002. LNCS, vol. 2386, pp. 209–232. Springer, Heidelberg (2002)
Schoenmakers, B.: Inorder traversal of a binary heap and its inversion in optimal time and space. In: Bird, R.S., Woodcock, J.C.P., Morgan, C.C. (eds.) MPC 1992. LNCS, vol. 669, pp. 291–301. Springer, Heidelberg (1993)
van de Snepscheut, J.L.: Inversion of a recursive tree traversal. Technical Report JAN 171a, California Institute of Technology (May 1991), Available online at ftp://ftp.cs.caltech.edu/tr/cs-tr-91-07.ps.Z
von Wright, J.: Program inversion in the refinement calculus. Information Processing Letter 37, 95–100 (1991)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Mu, SC., Bird, R. (2003). Rebuilding a Tree from Its Traversals:. In: Ohori, A. (eds) Programming Languages and Systems. APLAS 2003. Lecture Notes in Computer Science, vol 2895. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-40018-9_18
Download citation
DOI: https://doi.org/10.1007/978-3-540-40018-9_18
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-20536-4
Online ISBN: 978-3-540-40018-9
eBook Packages: Springer Book Archive