Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please ASAP!! Question 1 (40 points A set is a collection of unordered items that contains no duplicates. Sets are important in Mathematics and are
Please ASAP!!
Question 1 (40 points A set is a collection of unordered items that contains no duplicates. Sets are important in Mathematics and are useful in programming to keep track of distinct items such as the courses someone registered for, or a person's friends in a social network. Implement a class called MySet that represents a set of integers. My.Setclass will be composed of a singly linked list object as a data member. You should use the list implementation (List that we went through in class. The class should use two member variables: items a singly linked list of integers sire: an integer variable that keeps track of the number of elements in the set The class should have the following functionalities: Function Prototype Description Myset The default constructor. Creates an empty set. int getsize() const Returns the number of elements in the set. bool is Empty )const Returns true if the set is empty, false otherwise. void add(int el) Adds a new element el to the set. The element is added only if the set does not have elas a member. void remove (int el) Removes el from the set. void intersection (Myset& T, Myset& I) The intersection of this and T. The result will be stored in I. I is the set containing the elements that are in both this and void Union (MySet& T, MySet& U) The union of this and T. The result will be stored in U. U is the set containing the elements that are in this or T, or both. U is a set, so there should be no duplicate items. Question 1 (40 points A set is a collection of unordered items that contains no duplicates. Sets are important in Mathematics and are useful in programming to keep track of distinct items such as the courses someone registered for, or a person's friends in a social network. Implement a class called MySet that represents a set of integers. My.Setclass will be composed of a singly linked list object as a data member. You should use the list implementation (List that we went through in class. The class should use two member variables: items a singly linked list of integers sire: an integer variable that keeps track of the number of elements in the set The class should have the following functionalities: Function Prototype Description Myset The default constructor. Creates an empty set. int getsize() const Returns the number of elements in the set. bool is Empty )const Returns true if the set is empty, false otherwise. void add(int el) Adds a new element el to the set. The element is added only if the set does not have elas a member. void remove (int el) Removes el from the set. void intersection (Myset& T, Myset& I) The intersection of this and T. The result will be stored in I. I is the set containing the elements that are in both this and void Union (MySet& T, MySet& U) The union of this and T. The result will be stored in U. U is the set containing the elements that are in this or T, or both. U is a set, so there should be no duplicate itemsStep 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