Hostname: page-component-7479d7b7d-k7p5g Total loading time: 0 Render date: 2024-07-13T20:13:03.189Z Has data issue: false hasContentIssue false

Purely Functional 1-2 Brother Trees

Published online by Cambridge University Press:  26 May 2009

RALF HINZE*
Affiliation:
Computing Laboratory, University of Oxford, Wolfson Building, Parks Road, Oxford OX1 3QD, England (e-mail: ralf.hinze@comlab.ox.ac.uk)
Rights & Permissions [Opens in a new window]

Extract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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.

Type
Functional Pearls
Copyright
Copyright © Cambridge University Press 2009

References

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.Google Scholar
Aho, A. V., Hopcroft, J. E. & Ullman, J. D. (1974) The Design and Analysis of Computer Algorithms. Addison-Wesley Publishing Company.Google Scholar
Bayer, R. (1972) Symmetric binary B-trees: Data structure and maintenance algorithms, Acta Inform., 1: 290306.CrossRefGoogle Scholar
Bird, R. (1998) Introduction to Functional Programming using Haskell. 2nd ed.Prentice Hall.Google Scholar
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.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
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).Google Scholar
Hinze, R. & Paterson, R. (2006) Finger trees: A simple general-purpose data structure, J. Funct. Program., 16 (2): 197217.CrossRefGoogle Scholar
Kahrs, S. (2001) Functional Pearl: Red-black trees with types, J. Funct. Program., 11 (4): 425432.CrossRefGoogle Scholar
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.CrossRefGoogle Scholar
Okasaki, C. (1998) Purely Functional Data Structures. Cambridge University Press.CrossRefGoogle Scholar
Okasaki, C. (1999) Functional pearl: Red-black trees in a functional setting, J. Funct. Program., 9 (4): 471477.CrossRefGoogle Scholar
Ottmann, T., Six, H.-W. & Wood, D. (1979) On the correspondence between AVL trees and brother trees, Computing, 23, 4354.CrossRefGoogle Scholar
Reade, C. (1992) Balanced trees with removals: An exercise in rewriting and proof, Sci. Comput. Program., 18 (2): 181204.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.