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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started