Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement an ADT called IntSet for sets of integers: an unordered collection of elements with no duplicates. Each object of class IntSet can hold zero

Implement an ADT called IntSet for sets of integers: an unordered collection of elements with no duplicates. Each object of class IntSet can hold zero or more integers in the range 0 through 100. A set should be represented internally as an array of ones and zeros. Array element arr[i] is 1 if integer i is in the set. Array element arr[j] is 0 if integer j is not in the set. The default constructor should initialize a set to an empty set, i.e., a set whose array representation contains all zeros.

ADT should support the following

-IntSet() default constructor

-constructor with one integer parameter: creates a set containing just the given integer exmaple; IntSet(10) will create a set {10}

-isEmpty()- bool, true is empty, ele false

-size()- returns the number of elements in the set, an integer between 0 and 100

-setPrint()- prints set to cout with entries surrounded by curly braces and separated by commas; returns nothing

-setUntion()- creates a third set which is the union of two existing sets

-setIntersection()-creates a third set which is the intersection of two existing sets

-relativeComplement()-creates a third set which is the set of elements that are in set A and not in set B

-summetricDifference()-creates a third set whose elements belong to set A or to set B but not both.

-isEqualTo()- returns true if the two sets are equal, false otherwise

Please include .h and .cpp and main test program. Code should be able to execute what is it the sample output.

-----------------------------------------------------SAMPLE OUTPUT-----------------------------------

Show and test the empty set...

Empty = {--- } has 0 elements.

The set is empty

S1 = { 1 } has 1 elements.

Set S1 is *not* empty

{ 0 } union {--- } = { 0 }

{ 0 1 } union { 2 3 } = { 0 1 2 3 }

{ 0 1 3 } union { 0 2 3 } = { 0 1 2 3 }

Intersection of { 0 1 3 } and { 3 } is: { 3 }

Relative complement of { 0 1 2 3 }and { 0 } is: { 1 2 3 }

Symmetric difference of { 0 2 3 } and { 0 1 3 } is: { 1 2 }

Set A: { 0 1 3 }

Set B: { 0 2 3 }

Set A is not equal to set B

---------------------END OF SAMPLE OUTPUT-----------------------------------------

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions