Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create class IntegerSet for which each object can hold integers in the range 0 through 100. A set is represented internally as an array of

Create class IntegerSet for which each object can hold integers in the range 0 through 100. A set is represented internally as an array of ones and zeros. Array element a[ i ] is 1 if integer i is in the set. Array element a[ j ] is 0 if integer j is not in the set. Provide two constructors for the class. (1) One constructor does not have any parameter. This constructor initializes a set to the so-called empty-set, i.e., a set whose array representation contains all zeros. (2) An additional constructor that receives an array of integers and the size of that array and uses the array to initialize a set object. Provide member functions for the common set operations. (1) A unionOfsets member function creates a third set that is the set-theoretic union of two existing sets (i.e. an element of the third arrays is set to 1 if that element is 1 in either or both of the existing sets, and an element of the third sets array is set to 0 if that element is 0 in each of the existing sets). (2) An intersectionOfSets member function which creates a third set which is the set-theoretic intersection of two existing sets (i.e. an element of the third sets array is set to 0 if that element is 0 in either or both of the existing sets, and an element of the third sets array is set to 1 if that element is 1 in each of the existing sets). (3) An insertElement member function inserts a new integer k into a set (by setting a[k] to 1). (4) A deleteElement member function that deletes integer m (by setting a[m] to 0). (5) A printSet member function prints a set as a list of numbers separated by spaces. Print only those elements that are present in the set (i.e. their position in the array has a value of 1). Print --- for an empty set. (6) An isEqualTo member function that determines whether two sets are equal. (7) An emptySet member function that sets all elements of set to 0. (8) An inputSet member function that reads value from user into the set. (9) A validEntry member function that determines a valid entry to the set (i.e. in the range 0 through 100). Separate your class definition from implementation. Your class definition must be stored in a file called IntegerSet.h. Your class implementation must be stored in a file called IntegerSet.cpp. Provide a driver program (hw2.cpp) to test capabilities of your IntegerSet class. A sample output is provided below

image text in transcribed

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

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

Explain the key areas in which service employees need training.

Answered: 1 week ago

Question

Understand the role of internal marketing and communications.

Answered: 1 week ago