previous | index | next

Implementing Binary Search Trees: Constructor

As an abstract data type (ADT), regard a BST as an object with three parts:

Scheme constructor:

     (define make-nonempty-tree
       (lambda (root left-subtree right-subtree)
         (list root left-subtree right-subtree)))
Suppose left and right are BSTs, and we create a new BST with:
     (define my-bst (make-nonempty-tree 4 left right))

previous | index | next