Question: Part 2 : Programming Create the abstract data type ( ADT ) for an integer set called IntSet One IntSet object represents one mathematical set
Part : Programming Create the abstract data type ADT for an integer set called IntSet
One IntSet object represents one mathematical set of nonnegative integers includes zero One set keeps track
of unique integers, whether integers are in the set or not. That ADT includes standard math set operations.
Implement the internal representation as follows:
An Intset object is implemented as a bool array internally, containing true and false. For example, if you call the
array set, then set num is true if the integer num is in the set, false if num is not in the set. Use "new" to
dynamically allocate memory for the array. One object's array stores one math set's values.
Develop a full class with the following operations:
operatort: returns the union of two sets, the set of elements that are contained in either or both sets.
Note do not call ary identifiers "union" as that is a keyword in C
operator: returns the intersection of two sets, the set of all elements that are common to both sets.
operator: returns the difference of two sets, say which is the set of all elements that are in set
but not in set BEg A then is
operator: assignment operator: assign one set to another. The righthand side replaces lefthand side.
operators : the union, intersection, difference assignment.
operators : bool equality and inequality, if the mathematical sets contain the same elements.
insert: insert an element into a set, has bool return value, eg bool success A Insert ;
Note: ignore invalid integers, return false, eg bool success A insert ;
If a value is already in the set and is inserted, return true
remove: remove an element from a set, bool return value, eg bool success A remove ;
Note: ignore invalid integers, return false, eg bool success A remove ;
isEmpty: determine if a set is empty or not, bool return value, eg if A isEmpty
isinset: determine if an integer is in the set or not,
eg if AisinsetNote: returns false for invalid integers
operator: Display & to represent the set containing the integers
and The empty set is displayed exactly as:
Output exactly as shown, inside curly braces with one blank before each number:
output no other blanks. Note that operatore should not do an endl.
operator: to input an entire set. Note: This is a simple loop to take integers; terminate at
some sentinel value, say Ignore invalid integers. Zero is valid as it is nonnegative,
All proper constructor and destructor functions; constructors initialize a set to
The "empty set" a set which has no elements or
A set that can take up to five values to be inserted into the set
eg Intset ;
Intset ; is an exact copy of
Set is the empty set. For implementation, you could use nullptr, but using an array of one element keeps it
cleaner. While A is currently the empty set, after the operator operator etc. is used, the set could
contain many values. Set B initially holds Set has a current largest value of also contains the value
The constructor for will ignore the but is initialized to contain and is is
is a deep copy of is & You must initially size the arrays by the parameters, egs array is
size s array is size s array is size etc. Later, after operations, the size may change, You may need to
make arrays larger for operations later eg; but since new and delete are costly operations,
typically, for efficiency reasons, you don't shrink arrays if less space is needed. One component of this
assignment is to be efficient, to minimize unnecessary new and delete operations.
Often, when more memory is needed for an array, applications will double the array size to minimize the number
of new and delete operations. Do not do that in your program. This is about practicing memory management
pro
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
