Question: contains ( ) - You must write the code for this method. This method returns whether or not a value is in the set. uniqueElements

contains()- You must write the code for this method. This method returns whether or not a value is in the set.
uniqueElements()- You must write the code for this method. It takes an array and creates a new array with the
unique elements from the original. For example, [1,3,1,2,1] will return a new array containing [1,2,3].
Sorting will help with this method so be sure to first write a sorting algorithm, either Quick, Merge, or Radix for
int arrays. An approach is to count the number of unique values (sorting will help), create an array of size equal
to the number of unique elements, and then copy the unique elements to this array.
union()- You must write the code for this method. This is the mathematical union on two sets which creates a
new set that contains all the elements from both sets. For example, [1,2,3] U [2,3,5,6] results in a new set [1,
2,3,5,6]. This should not modify either set but instead creates a new IntegerSet object to return.
Intersection()- You must write the code for this method. This is the mathematical intersection operation on two
sets that returns a new set that contains elements that belong to both sets. For example, [1,2,3][2,3,4,5,
6] results in a new set [2,3]. An approach is to loop through the elements of the smaller set and use the
contains method of the larger set and only add the elements found in both. You may also need to use the
truncateArray method in the intArrayOperations class to clean up your result. This should not modify either set
but instead creates a new IntegerSet object to return

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!