Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Exercise Create a class called IntegerSet. Each object of class IntegerSet can hold integers in the range o through the size of the set

C++ Exercise

Create a class called IntegerSet. Each object of class IntegerSet can hold integers in the range o through the size of the set (or 100 if not specified). Internally, a set is represented as an array of ones and zeros. The element at index i is set to zero if i is not included in the set, or 1 otherwise. 1. Provide two constructors for the class. o The first constructor takes the size of the set, and initialize the array accordingly. Originally, all the values are zeros. o The default constructor initialize an array of 100 elements. 2. Implement the function - intersection - that creates a third set that contains the common elements between two sets. 3. Implement the function union that create a third set that contains the elements from both sets. 4. Provide an insertElement function that inserts a new integer k into a set (by setting a[k] to 1) 5. Implement a deleteElement function that deletes an element from a set (its sets the value at the corresponding index to 0) 6. Implement a function setPrint that prints a set as a list of numbers separated by space. 7. Implement a function isEqualTo that determines if two sets are equal (same size and same elements). 8. Keep track of the number of sets created (by using static function and static data member). 9. Implement the class destructor. 10. Provide a driver to test your code.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions