Standard Template Library
6.Which C++ STL container provides fast insertion and removal of elements from both ends?
-
A. Set
-
B. Map
-
C. List
-
D. Deque
Deque
Deque
7.In C++ STL, which of the following is true about the set container?
-
A. It allows duplicate elements.
-
B. It allows fast access by index.
-
C. It stores unique elements in sorted order.
-
D. It is implemented as a hash table.
It stores unique elements in sorted order.
It stores unique elements in sorted order.
8.What does the find() function do in a C++ STL map?
-
A. It returns the first element.
-
B. It searches for a key and returns the corresponding value.
-
C. It finds the minimum value.
-
D. It removes an element.
It searches for a key and returns the corresponding value.
It searches for a key and returns the corresponding value.
9.What is the time complexity of accessing an element in a vector by index in C++ STL?
-
A. O(n)
-
B. O(log n)
-
C. O(1)
-
D. O(n log n)
O(1)
O(1)
10.Which of the following is true about the C++ STL unordered_map?
-
A. It stores keys in sorted order.
-
B. It stores elements in hash table and allows fast access.
-
C. It is implemented using a balanced tree structure.
-
D. It allows duplicate keys.
It stores elements in hash table and allows fast access.
It stores elements in hash table and allows fast access.