Question: You must implement three functions from each of the Set, . In some cases, these functions are already defined in Racket (DrRacket). To avoid confusion,

You must implement three functions from each of the Set, . In some cases, these functions are already defined in Racket (DrRacket). To avoid confusion, you can name yours differently, for example myreverse for reverse. Or you can just override the built-in definition. You may use other builtin functions, such as if, cond, car (first), cdr (rest), and cons in your functions. But you may not, of course, use a builtin function in your answer for that same function. (must be in real code)

Set functions use lists to represent sets, but of course sets may not contain duplicate elements. You must implement at least three of these set functions.

1. Set membership (member a (b c a d)) => #t

2. Insert element into set (insert a (b c d)) => (a b c d) (insert a (a b c d)) => (a b c d)

3. Set intersection (intersection (a b c) (a c d)) => (a c) 4

4. Set union (union (a b c) (a c d)) => (a b c d)

5. Set difference (difference (a b c) (a c d)) => (b) (difference (a c d) (a b c)) => (d)

6. Symmetric difference (disjunctive union) (symdiff (a b c) (a c d)) => (b d)

7. Check if subset or equal () (subset? (a b) (a b c d)) => #t

8. Check if superset or equal () (superset? (a b c d) (a b)) => #t

9. Cardinality (cardinality (a b c)) => 3

10. Power set (if you need a hint, check Wikipedia) (powerset ()) => (()) (powerset (a b c)) => (() (a) (b) (c) (a b) (a c) (b c) (a b c))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!