Skip to main content

Purely Functional 1-2 Brother Trees

  • RALF HINZE (a1)

Enter the computing arboretum and you will find a variety of well-studied trees: AVL trees (Adel'son-Vel'skiĭ & Landis 1962), symmetric binary B-trees (Bayer 1972), Hopcroft's 2-3 trees (Aho et al. 1974), the bushy finger trees (Guibas et al. 1977) and the colourful red-black trees (Guibas & Sedgewick 1978). In this pearl, we look at a more exotic species of balanced search trees, 1-2 brother trees (Ottmann et al. 1979), which deserves to be better known. Brother trees lend themselves well to a functional implementation with deletion (Section 5) as straightforward as insertion (Section 3), both running in logarithmic time. Furthermore, brother trees can be constructed from ordered lists in linear time (Section 4). With some simple optimisations in place, this implementation of search trees is one of the fastest around. So, fasten your seat belts.

Hide All
Adel'son-Vel'skiĭ, G. & Landis, Y. (1962) An algorithm for the organization of information, Dokl. Akad. Nauk SSSR, 146: 263266. English translation in Soviet Math. Dokl. 3: pp. 12591263.
Aho, A. V., Hopcroft, J. E. & Ullman, J. D. (1974) The Design and Analysis of Computer Algorithms. Addison-Wesley Publishing Company.
Bayer, R. (1972) Symmetric binary B-trees: Data structure and maintenance algorithms, Acta Inform., 1: 290306.
Bird, R. (1998) Introduction to Functional Programming using Haskell. 2nd ed.Prentice Hall.
Guibas, L. J., McCreight, E. M., Plass, M. F. & Roberts, J. R. (1977) A new representation for linear lists. In Conference Record of the 9th Annual ACM Symposium on Theory of Computing, Boulder, Colorado, United States, pp. 49–60.
Guibas, L. J. & Sedgewick, R. (1978) A dichromatic framework for balanced trees. In Proceedings of the 19th Annual Symposium on Foundations of Computer Science. IEEE Computer Society, pp. 8–21.
Hinze, R. (1999) Constructing red-black trees. In Proceedings of the Workshop on Algorithmic Aspects of Advanced Programming Languages, WAAAPL'99, Paris, France, Okasaki, C. (ed). Columbia University, pp. 89–99 (Technical Report, CUCS-023-99).
Hinze, R. & Paterson, R. (2006) Finger trees: A simple general-purpose data structure, J. Funct. Program., 16 (2): 197217.
Kahrs, S. (2001) Functional Pearl: Red-black trees with types, J. Funct. Program., 11 (4): 425432.
Myers, E. W. (1984) Efficient applicative data types. In Proceedings of the 11th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, Salt Lake City, UT, Kennedy, Ken, van Deusen, Mary S., and Landweber, Larry (eds.). ACM, pp. 66–75.
Okasaki, C. (1998) Purely Functional Data Structures. Cambridge University Press.
Okasaki, C. (1999) Functional pearl: Red-black trees in a functional setting, J. Funct. Program., 9 (4): 471477.
Ottmann, T., Six, H.-W. & Wood, D. (1979) On the correspondence between AVL trees and brother trees, Computing, 23, 4354.
Reade, C. (1992) Balanced trees with removals: An exercise in rewriting and proof, Sci. Comput. Program., 18 (2): 181204.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *


Full text views

Total number of HTML views: 0
Total number of PDF views: 21 *
Loading metrics...

Abstract views

Total abstract views: 140 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 25th June 2018. This data will be updated every 24 hours.

Purely Functional 1-2 Brother Trees

  • RALF HINZE (a1)
Submit a response


No Discussions have been published for this article.


Reply to: Submit a response

Your details

Conflicting interests

Do you have any conflicting interests? *