Set STL Quiz Question 7

How the maximum possible size of mySet is calculated?

Please copy and paste question here.

struct comp
{
bool operator() (unsigned int x, unsigned int y) {
return (x % 10) < (y % 10);
}
}

set < unsigned int, comp > mySet = {9, 12};
for ( int x : mySet) cout << x << ' ';

What is the output? What is the maximum possible size of mySet?

depends upon the memory available, output is 12 9

10^8 , output is 12 9

10^1 , output is 12 9

10^2 , output is 9 12

@keshavbansal509 Output will be 12 9.
You can check the maximum possible size of the set using set_name.max_size() function.


Check this.


See the output for your question.
Maximum possible size of stl containers depend upon the system/upon the memory available.

Thanks :smiley:
So there is a correction, in the quiz option © is marked as correct.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.