InterviewStack.io LogoInterviewStack.io

Data Structure Selection and Trade Offs Questions

Skill in selecting appropriate data structures and algorithmic approaches for practical problems and performance constraints. Candidates should demonstrate how to choose between arrays lists maps sets trees heaps and specialized structures based on access patterns memory and CPU requirements and concurrency considerations. Coverage includes case based selection for domain specific systems such as games inventory or spatial indexing where structures like quadtrees or spatial hashing are appropriate, and language specific considerations such as value versus reference types or object pooling. Emphasis is on explaining rationale trade offs and expected performance implications in concrete scenarios.

EasyTechnical
79 practiced
Implement conceptually (no full code required) how you would use a heap (priority queue) to maintain the top-k tokens by logit score during beam search in a language model. Explain time and memory complexity per step and why a heap is appropriate versus sorting the entire vocabulary each step.
MediumTechnical
80 practiced
Compare CSR (Compressed Sparse Row) and COO (Coordinate) formats for representing sparse input matrices fed into GPU-accelerated models. Discuss conversion cost, memory layout benefits when transferring to GPU, batching trade-offs, and which formats deep learning libraries (PyTorch/TensorFlow) prefer for sparse ops.
HardTechnical
62 practiced
For extremely long-context transformers (e.g., up to 1M tokens), propose memory-efficient representations for attention masks and sparse attention patterns. Discuss compressed bitset representations, run-length encoding, block-sparse masks, and GPU constraints such as bank conflicts and shared memory limits. Estimate memory usage and algorithmic complexity of computing attention for your chosen approach.
HardSystem Design
83 practiced
Design a vector similarity search system that can serve 100B embeddings and deliver median query latency under 10ms. Explain the data structures (compressed indexes, inverted lists, HNSW overlays), sharding/replication strategy, caching layers, quantization strategy (PQ/OPQ), and hardware considerations (NVMe, GPU, memory) needed to meet latency and storage constraints.
MediumTechnical
115 practiced
You need to keep frequency estimates of tokens from a massive corpus to identify stopwords and rare tokens. Compare Count-Min Sketch, HashMap, and exact frequency approaches. Discuss memory and update time trade-offs, error bounds, effects on vocabulary selection for an NLP model, and how to choose sketch parameters for needed accuracy.

Unlock Full Question Bank

Get access to hundreds of Data Structure Selection and Trade Offs interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.