Abstract
First, we present a simple algorithm which, given a sorted sequence of node values, can build a binary search tree of minimum height in O(N) time. The algorithm works with sequences whose length is, a priori, unknown. Previous algorithms [1–3] required the number of elements to be known in advance. Although the produced trees are of minimum height, they are generally unbalanced. We then show how to convert them into optimal trees with a minimum internal path length in O(log N) time. The trees produced, both minimum height and optimal, have characteristic shapes which can easily be predicted from the binary representation of tree size.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Wirth, N.: Algorithms + data structures=programs. Prentice-Hall, Englewood Cliffs (1976)
Carrano, F.M., Prichard, J.J.: Data abstraction and problem solving with Java: walls and mirrors, 1st edn. Addison-Wesley, Boston (2001)
Carrano, F.M., Helman, P., Veroff, R.: Data structures and problem solving with Turbo Pascal: walls and mirrors. Benjamin/Cummings Pub. Co., Redwood City; Don Mills (1993)
Adelson-Velskii, G.M., Landis, E.M.: An Algorithm for the Organization of Information, Soviet Mathematics (translated from Doklady Akademii Nauk, SSSR), vol. 3, pp. 1259–1263 (1962)
Weiss, M.A.: Data Structures and Algorithm Analysis in Java. Addison-Wesley, Reading (1999)
Knuth, D.E.: The art of computer programming: Sorting and searching., vol. 3. Addison-Wesley Pub. Co., Reading (1973)
Dahl, O.-J., Myhrhaug, B., Nygaard, K.: SIMULA-67 Common Base Language, Norwegian Computer Centre, Oslo, Norway, Technical Report (1970)
Dahl, O.-J., Hoare, C.A.R.: Hierarchical Program Structures, in Structured Programming. A.P.I.C. Studies in Data Processing, vol. 8, pp. 175–220. Academic Press, London (1972)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2004 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Vaucher, J.G. (2004). Building Optimal Binary Search Trees from Sorted Values in O(N) Time. In: Owe, O., Krogdahl, S., Lyche, T. (eds) From Object-Orientation to Formal Methods. Lecture Notes in Computer Science, vol 2635. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-39993-3_17
Download citation
DOI: https://doi.org/10.1007/978-3-540-39993-3_17
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-21366-6
Online ISBN: 978-3-540-39993-3
eBook Packages: Springer Book Archive