1 ;; Exercise 3.26. To search a table as implemented above, one needs to scan through the list of records. This is basically the unordered list representation of section 2.3.3. For large tables, it may be more efficient to structure the table in a different manner. Describe a table implementation where the (key, value) records are organized using a binary tree, assuming that keys can be ordered in some way (e.g., numerically or alphabetically). (Compare exercise 2.66 of chapter 2.)
4 (define (make-tree key value left right)
5 (list key value left right))
10 (define (left-branch tree)
12 (define (right-branch tree)
16 (make-tree '*table* '() '()))
18 (define (assoc key tree)
19 (cond ((null? tree) (error "assoc passed empty tree"))
20 ((= key (entry tree)) tree)
21 ((< key (entry tree)) ...)
25 (define (insert! key value table)