At the architect level, you are rarely asked to implement a red-black tree from memory — but you are expected to instantly know which structure fits a problem, and to be able to build a clean, correct implementation of the common ones under time pressure. The table below is the one to have memorized cold.
| Data Structure | Access | Search | Insert | Delete | Space | Best Used For |
|---|---|---|---|---|---|---|
| Array (static) | O(1) | O(n) | O(n) | O(n) | O(n) | Fixed-size, index-based access, cache-friendly iteration |
| Dynamic Array (List/ArrayList) | O(1) | O(n) | O(1) amortized | O(n) | O(n) | General-purpose sequential collection |
| Singly Linked List | O(n) | O(n) | O(1) at head | O(1) at head | O(n) | Frequent head insert/delete, unknown size |
| Doubly Linked List | O(n) | O(n) | O(1) w/ reference | O(1) w/ reference | O(n) | LRU caches, deques, undo/redo stacks |
| Stack (array/list) | O(n) | O(n) | O(1) push | O(1) pop | O(n) | DFS, backtracking, expression evaluation, undo |
| Queue (deque) | O(n) | O(n) | O(1) enqueue | O(1) dequeue | O(n) | BFS, task scheduling, sliding window |
| Hash Map / Dictionary | O(1) avg | O(1) avg | O(1) avg | O(1) avg | O(n) | Fast lookup, counting, memoization, caching |
| Binary Search Tree (balanced) | O(log n) | O(log n) | O(log n) | O(log n) | O(n) | Ordered data, range queries |
| Heap (binary) | O(1) peek | O(n) | O(log n) | O(log n) | O(n) | Priority queues, top-K, scheduling |
| Trie (prefix tree) | O(k)* | O(k)* | O(k)* | O(k)* | O(ALPHABET × N × k) | Autocomplete, prefix search, spell-check |
| Graph (adjacency list) | O(1) edge check** | O(V+E) traversal | O(1) | O(degree) | O(V+E) | Networks, dependency graphs, routing |
| Union-Find (Disjoint Set) | — | O(α(n)) ≈ O(1) | O(α(n)) | — | O(n) | Connected components, cycle detection, Kruskal’s MST |
| Skip List | O(log n) avg | O(log n) avg | O(log n) avg | O(log n) avg | O(n log n) | Concurrent sorted sets (Redis sorted sets) |
| B-Tree / B+ Tree | O(log n) | O(log n) | O(log n) | O(log n) | O(n) | Database indexes, filesystem indexes |
*k = length of the string/key. **Adjacency list edge existence check is O(degree) in the worst case, O(1) with an adjacency set.
Architect-level framing for each structure
Arrays vs Linked Lists — arrays win on cache locality (contiguous memory → CPU prefetching) and are almost always faster in practice for anything under a few million elements, even for “O(n) insert” operations, because linked-list pointer chasing causes cache misses. Only reach for a linked list when you need true O(1) splice operations on both ends with references already in hand (e.g., LRU cache internals, deque implementations).
Hash Map collision resolution — two families: separate chaining (linked list/tree per bucket — Java’s HashMap) and open addressing (linear/quadratic probing, robin hood hashing — Python’s dict, Rust’s HashMap). Open addressing has better cache locality but degrades badly near high load factors; chaining degrades more gracefully. Always know your language’s default (C#'s Dictionary<K,V> uses chaining with a bucket array of prime sizes; Python’s dict uses open addressing with pseudo-random probing).
Trees — for interview purposes, distinguish: Binary Search Tree (unbalanced, can degrade to O(n)), AVL/Red-Black Tree (self-balancing, O(log n) guaranteed — .NET’s SortedDictionary and SortedSet are red-black trees), B-Trees (optimized for disk/page reads — every database index), and Tries (character-by-character, used for autocomplete and IP routing tables).
Heaps — binary heaps (array-backed, heapq in Python, PriorityQueue<TElement,TPriority> in .NET) are the default. For decrease-key operations at scale (Dijkstra’s on huge graphs) a Fibonacci heap gives amortized O(1) decrease-key, but in practice a binary heap with lazy deletion is what’s actually used in production systems.
Union-Find — the unsung hero of distributed systems interviews. With path compression + union by rank, near-constant time per operation. Used for: detecting cycles in undirected graphs, Kruskal’s MST, network connectivity, “number of provinces” style problems, and dynamic connectivity in service mesh topology analysis.