bst - (define (adjoin-set x set) (cond ((null? set)...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
(define (entry tree) (car tree)) (define (left-branch tree) (cadr tree)) (define (right-branch tree) (caddr tree)) (define (make-tree entry left right) (list entry left right)) (define (element-of-set? x set) (cond ((null? set) #f) ((= x (entry set)) #t) ((< x (entry set)) (element-of-set? x (left-branch set))) ((> x (entry set)) (element-of-set? x (right-branch set)))))
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (define (adjoin-set x set) (cond ((null? set) (make-tree x '() '())) ((= x (entry set)) set) ((&lt; x (entry set)) (make-tree (entry set) (adjoin-set x (left-branch set)) (right-branch set))) ((&gt; x (entry set)) (make-tree (entry set) (left-branch set) (adjoin-set x (right-branch set))))))...
View Full Document

This note was uploaded on 11/30/2010 for the course EECS 21281 taught by Professor Harvey during the Spring '10 term at University of California, Berkeley.

Ask a homework question - tutors are online