Explain C++ vector, unordered_map, and virtual functions | Jump Trading
|Home/Coding & Algorithms/Jump Trading
Explain C++ vector, unordered_map, and virtual functions
Jump Trading
Jul 16, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
0
0
In C++, explain:
The amortized and worst-case time complexity of vector::push_back, and how capacity growth/expansion is implemented (growth factor, reallocation steps, move vs. copy semantics, and iterator/reference invalidation rules).
How unordered_map is implemented under the hood: hashing function usage, bucket array layout, collision handling (e.g., chaining), load factor thresholds, rehashing strategy, iterator/reference invalidation, and expected time complexity guarantees for insert/find/erase.
The purpose of virtual functions, how dynamic dispatch works (vtables/vptr), associated runtime and memory costs, when virtual destructors are needed, and trade-offs versus alternatives (templates, static polymorphism).