Sunday, June 7, 2009

Ex-2.60

;element-of-set? stays the same and
; is O(n) operation

;adjoin-set
;its a O(1) operation now
(define (adjoin-set x set)
(cons x set))

;union-set
;its a O(n) operation now
(define (union-set set1 set2)
(append set1 set2))

;intersection-set stays the same and
;is O(n^2) operation

No comments:

Post a Comment