Give an implementation of adjoin-set using the ordered representation. By analogy with element-of-set? show how to take advantage of the ordering to produce a procedure that requires on the average about half as many steps as with the unordered representation.
(define (adjoin-set x set) (define (rec subset) (cond ((null? subset) (list x)) ((> x (car subset)) (cons (car subset) (rec (cdr subset)))) (else (cons x subset)))) (if (element-of-set? x set) set (rec set)))
Can this be improved?