

A

Interviewers ask this question to evaluate whether you can connect core data structures to real engineering constraints, not just recite definitions. A strong answer shows that you understand access patterns, complexity, memory trade-offs, and operational needs.
Describe one data structure you used in a real or hypothetical project and explain why you chose it.
Address these points:
The interviewer expects a concrete, engineering-focused explanation rather than a generic definition. Use one specific example, discuss the dominant read/write/query patterns, and justify the choice with complexity and practical constraints.
The right data structure depends on the operations you perform most often: lookup, insertion, deletion, ordering, or range queries. Interviewers want to hear that you chose the structure based on workload, not familiarity.
ops = ['lookup', 'insert', 'top_k'] # Identify dominant operations first
No data structure is universally best. A strong answer explains what was optimized, such as constant-time lookup or sorted retrieval, and what costs were accepted, such as extra memory or slower updates.
Big-O matters, but interviewers also care about implementation simplicity, maintainability, and real-world performance. A theoretically optimal structure may be a poor choice if the workload is small or the code becomes fragile.
cache = {} # Simpler than a custom balanced tree when exact lookup dominates
A complete answer compares the chosen structure with at least one realistic alternative. This shows judgment and helps demonstrate that the choice was deliberate rather than accidental.
Your explanation should tie the structure to a concrete system component, such as caching, ranking, scheduling, or graph traversal. This makes the answer credible and easier to evaluate.
top_items = [] # heap for ranking
adj = {} # graph for relationships