Skip to main content

Rebuilding a Tree from Its Traversals:

A Case Study of Program Inversion

  • Conference paper
Programming Languages and Systems (APLAS 2003)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2895))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Abramov, S.M., Glück, R.: The universal resolving algorithm: inverse computation in a functional language. Science of Computer Programming 43, 193–299 (2002)

    Article  MATH  MathSciNet  Google Scholar 

  2. 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)

    Google Scholar 

  3. 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)

    Google Scholar 

  4. Bird, R.S., de Moor, O.: Algebra of Programming. International Series in Computer Science. Prentice Hall, Englewood Cliffs (1997)

    MATH  Google Scholar 

  5. Chen, W., Udding, J.T.: Program inversion: more than fun! Science of Computer Programming 15, 1–13 (1990)

    Article  MATH  MathSciNet  Google Scholar 

  6. Dijkstra, E.W.: Program inversion. Technical Report EWD671, Eindhoven University of Technology (1978)

    Google Scholar 

  7. 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)

    Google Scholar 

  8. Harrison, P.G., Khoshnevisan, H.: On the synthesis of function inverses. Acta Informatica 29, 211–239 (1992)

    Article  MATH  MathSciNet  Google Scholar 

  9. 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)

    Chapter  Google Scholar 

  10. Knuth, D.E.: The Art of Computer Programming: Fundamental Algorithms, 3rd edn., vol. 1. Addison Wesley, Reading (1997)

    MATH  Google Scholar 

  11. de Moor, O., Gibbons, J.: Pointwise relational programming. In: Rus, T. (ed.) AMAST 2000. LNCS, vol. 1816, pp. 371–390. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  12. Mu, S.-C.: A Calculational Approach to Program Inversion. PhD thesis, Oxford University Computing Laboratory (2003)

    Google Scholar 

  13. 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)

    Chapter  Google Scholar 

  14. 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)

    Google Scholar 

  15. 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

  16. von Wright, J.: Program inversion in the refinement calculus. Information Processing Letter 37, 95–100 (1991)

    Article  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics