Logo

Question preview

How many copies?

What this preview is

About this preview

How many copies? is a cracked quant interview question on computer architecture in Cpp, asked at Quant.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

Understanding string copies across the network stack in C++

This is an open-ended reasoning question that tests your mental model of how data flows through multiple layers of a system—from the network hardware, through the kernel and standard library, to your application code. It's the kind of question quant firms ask to see whether you think deeply about the real cost of seemingly simple operations like push_back.

The question asks you to count copies in the worst case, starting from wire arrival. This means reasoning about what happens in the kernel's network stack (driver, socket buffer, TCP reassembly), the C++ runtime (temporary objects during string construction and vector growth), and memory management (alignment, allocation patterns). A strong answer identifies the key transition points where copies occur—and crucially, where they might be elided or avoided.

  • Network stack and kernel buffering behaviour
  • String move semantics and temporary objects
  • std::vector growth strategy and reallocation
  • Copy elision and return-value optimisation in modern C++