Question: Write a union function in a file named union.sml of type int int list int list int list. It will take two lists that are

Write a union function in a file named union.sml of type int int list int list int list. It will take two lists that are in order from smallest to largest with no duplicates within the list and produce a list with a single copy of all elements from both lists. The resulting list must also be in order from smallest to largest. Make sure you do this efficiently. It should be O(m+n), not O(m**n). Example: union [1,4,6][3,4,5] will return 1,3,4,5,6.
Write an intersection function in a file named intersection.sml. This will be much like union, but with the result containing only those elements that appear in both lists. All lists will be in order from smallest to largest, and efficiency matters. Example: intersection ,8] will return 4,6.
Write a find_subset function in a file named find_subset.sml of type int -> int list -> int list. It will return a subset of the list that adds up to the first argument. If no such subset can be found, it will return the empty list. Examples:
find_subset 10[4,3,2,12,5] should return 3,2,5
find_subset 10[4,3,2,12] should return []
Your resulting list must have the values in the same order and must identify the same subset that is specified here. Under no circumstance will the parameters include 0 or negative numbers for this problem.
Write a union function in a file named union.sml

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 Programming Questions!