A fresh look at binary search trees

  • Authors:
  • Ralf Hinze

  • Affiliations:
  • Institute of Information and Computing Sciences, Utrecht University, P.O.Box 80.089, 3508 TB Utrecht, The Netherlands (e-mail: ralf@cs.uu.nl)

  • Venue:
  • Journal of Functional Programming
  • Year:
  • 2002

Quantified Score

Hi-index 0.00

Visualization

Abstract

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.