Abstract
In this paper we derive a linear-time, constant-space algorithm to construct a binary heap whose inorder traversal equals a given sequence. We do so in two steps. First, we invert a program that computes the inorder traversal of a binary heap, using the proof rules for program inversion by W. Chen and J.T. Udding. This results in a linear-time solution in terms of binary trees. Subsequently, we data-refine this program to a constant-space solution in terms of linked structures.
Preview
Unable to display preview. Download preview PDF.
References
Andersson, A., Catlsson, S.: Construction of a Tree from its Traversals in Optimal Time and Space. Information Processing Letters 34 (1990) 21–25
Bird, R.S.: Lectures on Constructive Functional Programming. Technical monograph PRG 69, Oxford University Computing Laboratory (1988)
Chen, W., Udding, J.T.: Program Inversion: More Than Fun! Science of Computer Programming 15 (1990) 1–13
Gabow, H.N., Bentley, J.L., Tarjan, R.E.: Scaling and related techniques for geometry problems. Proc. 16th Annual ACM Symposium on Theory of Computing (1984) 135–143
Gries, D.: Inorder Traversal of a Binary Tree. In: E.W. Dijkstra (ed.), The Formal Development of Programs and Proofs, Addison-Wesley, Amsterdam (1990)
Gries, D., v.d. Snepscheut, J.L.A.: Inorder Traversal of a Binary Tree and its Inversion. In: E.W. Dijkstra (ed.), The Formal Development of Programs and Proofs, Addison-Wesley, Amsterdam (1990)
Levcopoulos, Ch., Petersson, O.: Heapsort—Adapted for Presorted Files. In: F. Dehne, J.-R. Sack, N. Santoro (eds.), Algorithms and Data Structures, LNCS 382 (1989) 499–509
Vuillemin, J.: A unifying look at data structures. Communications of the ACM 23 (1980) 229–239
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1993 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Schoenmakers, B. (1993). Inorder traversal of a binary heap and its inversion in optimal time and space. In: Bird, R.S., Morgan, C.C., Woodcock, J.C.P. (eds) Mathematics of Program Construction. MPC 1992. Lecture Notes in Computer Science, vol 669. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-56625-2_19
Download citation
DOI: https://doi.org/10.1007/3-540-56625-2_19
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-56625-0
Online ISBN: 978-3-540-47613-9
eBook Packages: Springer Book Archive