Use a linked list representation to implement a class that holds a set of ints. A set is an unordered list with no duplicate elements. Name your class IntSet. There should be a constructor for the empty set, and a constructor for a set containing a single int. Provide the following methods:

a. int getVal() returns value of the first element in the set; if the set is empty, it should throw NullPointerException

b. IntSet getNext returns the sub-IntSet without the first element

c. boolean addInt(int e), adds e to the set, returning true iff e was not already present and was added

d. boolean containsInt(int e), true iff the set contains e

e. boolean equals(IntSet o), true iff both sets have the same elements

f. boolean isEmpty(), true iff the set is empty

g. boolean remove(int e), true iff set contained e, so e was removed

h. int size(), returns the number of elements

i. String to String, returns a representation of the set as a string

j. IntSet intersection(IntSet o), returns the intersection of the sets

k. IntSet union(IntSet o), returns the union of the sets

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.