Question: please help me write this two methods in java: contains() This method returns true or false if a given value is in the set. Here
please help me write this two methods in java:
contains() This method returns true or false if a given value is in the set. Here is an example, IntegerSet iS1 = new IntegerSet([1,2,3,4]); iS1.contains(3); //returns true iS2.contains(6); //returns false Tips Remember that your set should be sorted. (See uniqueElements method). What algorithm can you use to complete this contains method? This method will be handy for you in a later method. uniqueElements() This method is called inside the constructor and is used to create the int array that represents an IntegerSet. The int array returned has the characteristics of having only unique elements and, incidentally, being sorted. This method takes an array like [1, 2, 1, 3, 1, 3, 2, 4] and returns an integer that will be [1, 2, 3, 4]. Tips You should use a temporary array that is the same size as the array being passed in to temporarily store the unique elements (making sure to also keep count) and return a truncated version of the temp array.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
