Question: PLEASE USE JAVA A set is a collection of elements in which no element occurs more than once (distinct elements). We can implement a simple
PLEASE USE JAVA
A set is a collection of elements in which no element occurs more than once (distinct elements). We can implement a simple set as a linked list to store the items in the set.
Fundamental Set operations are add(E element), remove(E element), union(Set
MySet
head
tail
size
+ MySet()
+ MySet(arr : E[])
+ MySet(otherList : List)
+ Boolean Add(element:E): boolean
+ Boolean Remove(element:E): boolean
+ union(otherSet: MySet
+ intersection(otherSet: MySet
+ difference(otherSet: MySet
The class should implement the MyList
Define and implement the following methods in MySet:
Boolean add(E element) : add element to the set, return true if element is added
Boolean remove(E element): remove element from the set, return true if element is found and removed
MySet
MySet
MySet
Write a test program that creates Three MySet instances, set1, set2 and set3 and show that the three constructors and all methods implemented in MySet class are working properly.MySet
MySet
Write a test program that creates Three MySet instances, set1, set2 and set3 and show that the three constructors and all methods implemented in MySet class are working properly.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
