Pattern

Choosing a data structure

Match a structure to the operations and scale a scenario actually needs, and defend the trade-off you didn't pick.

What it is

This is a reasoning skill, not one structure: given a scenario described by its operations (lookup, range query, ordered iteration, eviction, rank) and its scale, name the structure whose complexity profile fits, and be able to say why the next-most-obvious alternative loses. The interviewer is testing whether you go from "what is this data" to "what will be done to it, how often, and at what scale" before picking anything, and whether you can quantify the trade-off (memory, latency, amplification) rather than just naming a textbook structure that sounds thematically appropriate.

When it applies

Tells in the problem

The classic mistake

Naming a structure that matches the surface theme of the problem instead of the operation being asked about — reaching for a trie because the data is "words" when the actual requirement is plain membership testing, where a hash set is simpler and just as fast. The parallel mistake on the systems side is treating a structure's advertised complexity as unconditional: quoting "hash table lookup is O(1)" or "consistent hashing solves rebalancing" without naming what has to be true for that to hold (a hash function resistant to the actual key distribution, enough virtual nodes to balance load) leaves the claim unfalsifiable. The fix in both cases is the same: name the operation, name the cost under that operation, and name the condition under which an alternative would actually be better.

Questions to start with

All 5 choosing a data structure questions

Problem statement, examples and hints are free on every page; the worked approach, solution and tests are in the company guides.

Free starter pack

13 must-tier questions with full solutions

Sign in with an email — no purchase — and read them in the full reader.

No password, no spam. One sign-in email; you can read the pack in the full reader.