STL containers, iterators, algorithms, lambdas with algorithms, complexity guarantees and ranges.
39 cards · basic cards · AI-written, checked twice. Edit anything.
- What is the most versatile STL container for most use cases?
Show answer
vector
- Which container supports O(1) insertion and deletion at both ends?
Show answer
deque
- What is the key difference between std::list and std::vector?
Show answer
list is a linked list, vector is a dynamic array
- When should you use std::set instead of std::vector?
Show answer
when you need unique sorted elements with O(log n) insertion, deletion, and lookup
- What does std::map store?
Show answer
sorted key-value pairs
- What is the difference between std::map and std::unordered_map?
Show answer
map uses a tree (sorted), unordered_map uses a hash table
- What is std::forward_list?
Show answer
a singly-linked list container
- Name the three STL container adapters.
Show answer
stack, queue, priority_queue
- What is std::array?
Show answer
a fixed-size array wrapper that provides STL-compatible semantics
- What are the five iterator categories in C++?
Show answer
input, output, forward, bidirectional, random access
- Which STL containers support random-access iterators?
Show answer
vector, deque, array, string
- What operations does a forward iterator support?
Show answer
increment (++), dereference (*), and equality comparison (==)
- What operations does a bidirectional iterator support?
Show answer
increment (++), decrement (--), dereference (*), and equality comparison (==)
- What does iterator invalidation mean?
Show answer
an iterator no longer refers to a valid element in a container
- After which operations can std::vector iterators become invalid?
Show answer
after reallocation (push_back causing growth), erase, or clear