Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please do the find _ biggest _ subset _ le function C + + The Representationfasd How do you represent a set internally? At first
Please do the findbiggestsubsetle function CThe Representationfasd
How do you represent a set internally?
At first thought it might seem like a simple problem. The trivial solution is to have each set be a
collection eg a vector of objects.
While this seems like a simple solution on face value, it can be horribly inefficient. What if I
wanted to make sets of media objects that were each unmanageably large?
A better solution is to store all possible set members, the socalled Universal or Master set,
within the object as a class static member. Each instantiated set would then be simply
composed of a collection of integers, which are simply pointers to the actual objects in the
Master set.
This sounds like a good idea. But there's an even better one. With a static master set, you still
have to initialize it by copying over the supplied elements into it With an understanding that
you will not change the master set, why not have your client the instantiator of the Set class
create and maintain the master set as a vector, and you only deal with integer indices into this
externally maintained master set?
That's the approach we will take in this quest. Although you don't have to code a lot, most of the
time, I presume, may be taken up by simply wrapping your head around this:
The Set object will contain a pointer to an externally maintained vector of elements we
call the master set. This pointer must be set during set initialization.
Each Set object will contain a vector of integers, each of which is an index in the master
set to a valid element contained in that Set. See Figure class Set
private:
vectoraT
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