Hostname: page-component-8448b6f56d-jr42d Total loading time: 0 Render date: 2024-04-23T08:51:32.750Z Has data issue: false hasContentIssue false

A fresh look at binary search trees

Published online by Cambridge University Press:  06 November 2002

RALF HINZE
Affiliation:
Institute of Information and Computing Sciences, Utrecht University, P.O.Box 80.089, 3508 TB Utrecht, The Netherlands (e-mail: ralf@cs.uu.nl)
Rights & Permissions [Opens in a new window]

Abstract

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.

Binary search trees are old hat, aren't they? Search trees are routinely covered in introductory computer science classes and they are widely used in functional programming courses to illustrate the benefits of algebraic data types and pattern matching. And indeed, the operation of insertion enjoys a succinct and elegant functional formulation. Figure 1 contains the six-liner given in the language Haskell 98.

Alas, both succinctness and elegance are lost when it comes to implementing the dual operation of deletion, also shown in figure 1. Two additional helper functions are required causing the code size to double in comparison with insertion.

Type
FUNCTIONAL PEARL
Copyright
© 2002 Cambridge University Press
Submit a response

Discussions

No Discussions have been published for this article.