Logo

Question preview

So, how big is vector?

What this preview is

About this preview

So, how big is vector? is a medium quant interview question on language knowledge 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 C++ vector memory layout and size

This is a medium-difficulty C++ language-knowledge question that tests whether you understand the distinction between a vector's logical size, its capacity, and its underlying memory footprint. Quant firms ask questions like this to confirm candidates can reason about low-level memory behaviour—critical when optimizing for latency or working with large datasets in trading systems.

To answer correctly, you need to know how std::vector stores its metadata (typically a pointer to heap-allocated data, a size field, and a capacity field), how those fields are laid out on a 64-bit system, and what the sizeof() operator actually measures. The question rewards understanding that sizeof() reports the size of the vector object itself—not the memory it manages on the heap—and that this size is independent of how many elements the vector contains or how much space has been reserved.

  • Vector object vs. heap allocation
  • Size, capacity, and reserved memory
  • The sizeof() operator on container types
  • 64-bit pointer and metadata layout