Please answer the question in the screenshot. The language used here is in Racket. XXXXXXXXXX))--(union '((1 2 3)) '((3 4 5)) XXXXXXXXXX))--->(union '((1 2 3)) '((3 2 1))) --->...


Please answer the question in the screenshot. The language used here is in Racket.


Two common operations on sets are union and intersection. The union of two sets is the<br>set of all elements that appear in either set (with no repetitions). The intersection of two<br>sets is the set of elements that appear in both sets.<br>Write Racket functions (union S1 S2) and (intersect S1 S2) that implement set union<br>and set intersection.<br>For example:<br>(union '(1 (2) 3) '(3 2 1)) ·<br>-> (1 2 3 (2))<br>--<br>(union '((1 2 3)) '((3 4 5))<br>((1 2 3) (3 4 5))<br>---><br>(union '((1 2 3)) '((3 2 1))) ---> ((1 2 3))<br>(intersect '((1 2 3)) '((3 2 1)))<br>---> ((1 2 3))<br>(intersect '((1 2 3)) '((4 5 6))) ---> ()<br>(intersect '((1) (2) (3)) '((2) (3) (4))) ---> ((2) (3))<br>The ordering of the elements in your answer may differ from the above. You must use<br>recursion, and not iteration. You may not use side-effects (e.g. set!).<br>

Extracted text: Two common operations on sets are union and intersection. The union of two sets is the set of all elements that appear in either set (with no repetitions). The intersection of two sets is the set of elements that appear in both sets. Write Racket functions (union S1 S2) and (intersect S1 S2) that implement set union and set intersection. For example: (union '(1 (2) 3) '(3 2 1)) · -> (1 2 3 (2)) -- (union '((1 2 3)) '((3 4 5)) ((1 2 3) (3 4 5)) ---> (union '((1 2 3)) '((3 2 1))) ---> ((1 2 3)) (intersect '((1 2 3)) '((3 2 1))) ---> ((1 2 3)) (intersect '((1 2 3)) '((4 5 6))) ---> () (intersect '((1) (2) (3)) '((2) (3) (4))) ---> ((2) (3)) The ordering of the elements in your answer may differ from the above. You must use recursion, and not iteration. You may not use side-effects (e.g. set!).

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here