Questions and Answers
- What kind of library is Standard Template Library?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
The STL is a generic library, meaning that its components are heavily parameterized.
- What do maps and sets support?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Bi-directional iterators
- How many instance are allowed by map and set while inserting a element into container?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Both map and set only allow one instance of a key or element to be inserted into the container.
- What is the output of this program?
#include <iostream>
#include <set>
using namespace std;
int main ()
{
multiset<int> MultisetData;
for (int k = 0; k < 6; k++) MultisetData.insert(k);
multiset:: key_compare compare = MultisetData.key_comp();
int highest = *MultisetData.rbegin();
multiset:: iterator Iter = MultisetData.begin();
do
{
cout << ' ' << *Iter;
} while (compare(*Iter++, highest));
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, We used the set template and then we compared the keys and printing the result.
- What is the output of this program?
#include <iostream>
#include <set>
using namespace std;
int main ()
{
set<int> SetData;
SetData.insert(25);
SetData.insert(15);
SetData.insert(45);
SetData.insert(35);
SetData.insert(55);
while (!SetData.empty())
{
cout << ' ' << *SetData.begin();
SetData.erase(SetData.begin());
}
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
In this program, We used the set template and then we are initializing the values and then we are erasing it.