foundation
Data structures
Arrays, lists, stacks, queues, hash tables, trees, heaps, tries, and graphs.
Data structure questions test whether you can match access patterns to the right abstraction. Arrays excel at indexed access and sequential scans. Linked lists trade indexing for cheap pointer rewiring. Stacks and queues encode LIFO and FIFO invariants. Hash maps buy average O(1) lookup with extra memory. Trees and graphs model hierarchy and relationships; heaps support priority-based selection.
Before coding, ask: what operations dominate — lookup, insert, delete, min/max, prefix search, or traversal? The answer drives structure choice more than familiarity with a single pattern.
On interviews: name average and worst-case costs, compare at least two alternatives, and explain memory trade-offs.
Common pitfalls: using a hash map when sorted order matters; using Array.shift as a queue in performance-sensitive code; assuming a balanced tree when input may be skewed.
Checklist:
- List dominant operations.
- Compare time, space, and ordering guarantees.
- Pick child topics for depth on each structure.
- Test empty, single-element, and pathological inputs.