STL Containers interview questions

15 real STL Containers questions from the C++ bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.

1. What is std::vector?

Junior
  1. A.the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage
  2. B.a contiguous dynamic array offering amortized constant-time append and random access, the default sequence container choice
  3. C.a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
  4. D.an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
Reveal the answer + AI explanation — free account

2. Which term means: "a contiguous dynamic array offering amortized constant-time append and random access, the default sequence container choice"?

Junior
  1. A.std::map
  2. B.Iterator invalidation
  3. C.std::deque
  4. D.std::vector
Reveal the answer + AI explanation — free account

3. Which statement is correct?

Junior
  1. A.std::vector — a hash-table associative container giving average constant-time lookup but no ordering guarantee on its keys
  2. B.std::vector — a contiguous dynamic array offering amortized constant-time append and random access, the default sequence container choice
  3. C.std::vector — an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
  4. D.std::vector — the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage
Reveal the answer + AI explanation — free account

4. What is std::map?

Mid
  1. A.a contiguous dynamic array offering amortized constant-time append and random access, the default sequence container choice
  2. B.a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
  3. C.an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
  4. D.a hash-table associative container giving average constant-time lookup but no ordering guarantee on its keys
Reveal the answer + AI explanation — free account

5. Which term means: "an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal"?

Mid
  1. A.std::unordered_map
  2. B.std::deque
  3. C.std::map
  4. D.std::vector
Reveal the answer + AI explanation — free account

6. Which statement is correct?

Mid
  1. A.std::map — a hash-table associative container giving average constant-time lookup but no ordering guarantee on its keys
  2. B.std::map — a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
  3. C.std::map — an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
  4. D.std::map — a contiguous dynamic array offering amortized constant-time append and random access, the default sequence container choice
Reveal the answer + AI explanation — free account

7. What is std::unordered_map?

Mid
  1. A.an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
  2. B.the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage
  3. C.a hash-table associative container giving average constant-time lookup but no ordering guarantee on its keys
  4. D.a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
Reveal the answer + AI explanation — free account

9. Which statement is correct?

Mid
  1. A.std::unordered_map — a hash-table associative container giving average constant-time lookup but no ordering guarantee on its keys
  2. B.std::unordered_map — the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage
  3. C.std::unordered_map — a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
  4. D.std::unordered_map — a contiguous dynamic array offering amortized constant-time append and random access, the default sequence container choice
Reveal the answer + AI explanation — free account

10. What is std::deque?

Mid
  1. A.a contiguous dynamic array offering amortized constant-time append and random access, the default sequence container choice
  2. B.a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
  3. C.an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
  4. D.the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage
Reveal the answer + AI explanation — free account

11. Which term means: "a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees"?

Mid
  1. A.std::deque
  2. B.std::vector
  3. C.Iterator invalidation
  4. D.std::unordered_map
Reveal the answer + AI explanation — free account

12. Which statement is correct?

Mid
  1. A.std::deque — an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
  2. B.std::deque — the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage
  3. C.std::deque — a hash-table associative container giving average constant-time lookup but no ordering guarantee on its keys
  4. D.std::deque — a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
Reveal the answer + AI explanation — free account

13. What is Iterator invalidation?

Senior
  1. A.a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
  2. B.the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage
  3. C.an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
  4. D.a hash-table associative container giving average constant-time lookup but no ordering guarantee on its keys
Reveal the answer + AI explanation — free account

14. Which term means: "the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage"?

Senior
  1. A.std::map
  2. B.std::vector
  3. C.std::unordered_map
  4. D.Iterator invalidation
Reveal the answer + AI explanation — free account

15. Which statement is correct?

Senior
  1. A.Iterator invalidation — a double-ended sequence container supporting efficient insertion and removal at both front and back without contiguous storage guarantees
  2. B.Iterator invalidation — the event where adding elements forces a container to reallocate or rebalance, leaving previously held iterators pointing to freed or moved storage
  3. C.Iterator invalidation — an ordered associative container storing sorted unique keys, typically a balanced tree giving logarithmic lookup and ordered traversal
  4. D.Iterator invalidation — a contiguous dynamic array offering amortized constant-time append and random access, the default sequence container choice
Reveal the answer + AI explanation — free account

Free to start

Answers, AI explanations, and a scored voice mock interview

Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.

Practice STL Containers free