AppliedNumeric answer
A std::vector starts with capacity and doubles whenever it is full. How many reallocations happen during push_back calls?
Answer with a number. Fractions, powers and expressions like 23/6 or C(52,5) are read correctly in practice.
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Learn the method
C++ for trading: RAII, moves and what belongs on the hot path
Reported in interviews at
More systems and low latency questions
- Which of these is the most important thing to remove from a hot path?Applied
- On a typical 64-bit platform, what is sizeof of struct { char a; int32_t b; char c; }?Applied
- Why do low-latency C++ codebases avoid virtual function calls on the hot path?Applied
- What does std::move(x) do by itself?Applied
- Per-thread counters, part 2 of 3Applied
- What does returning a large std::vector by value cost in modern C++?Advanced