Question
PRACTICE PROBLEM #1 (DIFFICULTY LEVEL = EASY) Write a method named Complement for the Array of Booleans implementation of the Set ADT that takes a
PRACTICE PROBLEM #1 (DIFFICULTY LEVEL = EASY) Write a method named Complement for the Array of Booleans implementation of the Set ADT that takes a Set s1 as input. This method should store in the owning object the elements that were not in s1 Follow-On Thought Exercise: Why would we not be able to write this Complement( ) method for our Array of Integers implementation?
existing code (array of booleans):
bool Set::isMember (int element){
if (element = MAX)
{
cout
return false;
}
else
{
return elements[element];
}
}
void Set:: computeIntersection(Set a, Set b)
for (int i = 0; i
if(a.elements[i]==true && b.elements[i]==true){
elements[i] = true;
}
else{
elements[i] = false;
}
}
void Set::display()
for(int i = 0; i { if(elements[i] == true) { cout } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started