Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please someone help me with this ASAP. Create a class called IntegerSet. Each object of class IntegerSet can hold integers in the range 0 through

Please someone help me with this ASAP. 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 if i 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 centains the elements from both sets. 4. Provi ide an insertElement function that inserts a new integer k into a set (by setting alk] to 1) Implement a deleteElement function that deletes an element from a set (it sets the value at the corresponding index to 0) 5. 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 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 to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions