Which standard container gives average constant-time lookup by key?
-
A
std::list
-
B
std::unordered_map
Correct answer
-
C
std::map
-
D
std::vector
Correct answer
B. std::unordered_map
16 views
Explanation
std::unordered_map is a hash table, so lookups take constant time on average.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ