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, will return a new array containing
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, U results in a new set
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,
results in a new set 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
