Question: The Unordered List can be used to implement a discrete set. Create a new JAVA class called ListSetOperator, which will be used to perform set
The Unordered List can be used to implement a discrete set. Create a new JAVA class called "ListSetOperator", which will be used to perform set operations with UList objects. Program this without using hash set or tree set.
The class should include methods:
public UList union(UList Set 1, UList Set2) that returns a reference to a new list containing all of the items from Set1 or Set2 with no repeats,
public UList intersect(UList Set1, UList Set2) that returns a reference to a new list containing only the items from both Set1 and also Set2 with no repeats, and
public UList subtract(UList Set 1, UList Set2) that returns a reference to a new list containing all of the items that are in Set1 but not Set2
Make sure to Write a ListSetMain class to demonstrate that your methods work. Include code that displays the IDs of all of the elements in the resulting sets (in any order). Use "A', "B", "C",... as elements.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
