C++ STL Quiz 1 question no. 5,7,11,13

Q5- 3 was not in the array so will it first insert 3 in the array and then print the index at which 3 is present?

Q7 - if we are printing *it then why is it printing the index (i.e 6) instead of the value at that index(i.e 15)

Q13 - Didn’t understand the compare structure

Q15 - ret = s.insert(10);
cout<<ret.second<<endl;
ret was to take 2 arguments as it is of pair type. Then why did the code work even with 1 argument?

No it won’t insert 3, it will give you the index at which value is <= target.
In this case. Understand it with an example:
Input: 10 20 30 30 30 40 50
Output: lower_bound for element 30 at index 2

in the case when the element being searched is greater than the maximum element the set the returned value is number of elements in the set which in this case is 6.

By default it take value as false, so when you do ret.second without giving default value as true, it would show you 0 as false.

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.