Standard Template Library
16.In C++ STL, what is the default order of elements in a priority_queue?
-
A. Ascending
-
B. Descending
-
C. Random
-
D. It depends on the comparator used.
Descending
Descending
17.Which of the following containers would you use if you need an ordered collection of unique elements, but without duplicates?
-
A. Vector
-
B. Set
-
C. Multimap
-
D. Unordered_map
Set
Set
18.What does the emplace() function do in C++ STL containers?
-
A. It adds an element at the end.
-
B. It creates and inserts an element in place (more efficient).
-
C. It returns the element after insertion.
-
D. It searches for an element and removes it.
It creates and inserts an element in place (more efficient).
It creates and inserts an element in place (more efficient).
19.In C++ STL, what happens if you try to insert a duplicate key into a map container?
-
A. The duplicate key is ignored.
-
B. A runtime error occurs.
-
C. The value of the key is updated.
-
D. The insertion fails silently.
The duplicate key is ignored.
The duplicate key is ignored.