Skip to main content

Building Optimal Binary Search Trees from Sorted Values in O(N) Time

  • Chapter
From Object-Orientation to Formal Methods

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

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.

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

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.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. Wirth, N.: Algorithms + data structures=programs. Prentice-Hall, Englewood Cliffs (1976)

    MATH  Google Scholar 

  2. Carrano, F.M., Prichard, J.J.: Data abstraction and problem solving with Java: walls and mirrors, 1st edn. Addison-Wesley, Boston (2001)

    Google Scholar 

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

    Google Scholar 

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

    Google Scholar 

  5. Weiss, M.A.: Data Structures and Algorithm Analysis in Java. Addison-Wesley, Reading (1999)

    Google Scholar 

  6. Knuth, D.E.: The art of computer programming: Sorting and searching., vol. 3. Addison-Wesley Pub. Co., Reading (1973)

    Google Scholar 

  7. Dahl, O.-J., Myhrhaug, B., Nygaard, K.: SIMULA-67 Common Base Language, Norwegian Computer Centre, Oslo, Norway, Technical Report (1970)

    Google Scholar 

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

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics