Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

C++ classes image text in transcribed
Create a class called IntegerSet. Each object of class IntegerSet can hold integers in the range 0 through the size of the set (or 100 if not specified). Internally, a set is represented as a vector of ones and zeros. The element at index i is set to zero ifi is not included in the set, or 1 otherwise. 1. Provide two constructors for the class. The first constructor takes the size of the set, and initialize the vector accordingly. Originally, all the values are zeros. The default constructor initialize a vector 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 creates 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 (it sets the value at the corresponding index to o) 6. Implement a function setPrint that prints a set as a list of numbers separated by spaces 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. Provide a driver to test your code. That is, in your main function, create a set containing all the even integers between 0 and 100 (inclusive) and another set containing all the odd integers between 0 and 100 (inclusive). Now get the intersection, the union, and print those sets. Then modify the set contains all odd integers so that it also contains the element 0. Repeat the intersection and the union and print them. Create a class called IntegerSet. Each object of class IntegerSet can hold integers in the range 0 through the size of the set (or 100 if not specified). Internally, a set is represented as a vector of ones and zeros. The element at index i is set to zero ifi is not included in the set, or 1 otherwise. 1. Provide two constructors for the class. The first constructor takes the size of the set, and initialize the vector accordingly. Originally, all the values are zeros. The default constructor initialize a vector 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 creates 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 (it sets the value at the corresponding index to o) 6. Implement a function setPrint that prints a set as a list of numbers separated by spaces 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. Provide a driver to test your code. That is, in your main function, create a set containing all the even integers between 0 and 100 (inclusive) and another set containing all the odd integers between 0 and 100 (inclusive). Now get the intersection, the union, and print those sets. Then modify the set contains all odd integers so that it also contains the element 0. Repeat the intersection and the union and print them

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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