Every structure in this wiki, with a one-line “reach for this when…”.

Linear

StructureWhen
Array / vectorindexed access, cache locality, the default
Linked list splice at a known node; rarely worth it
StackLIFO; recursion, bracket matching, DFS
QueueFIFO; BFS, scheduling
Dequeboth ends; 0-1 BFS, sliding windows
Hash table lookup, order irrelevant
Prefix sumstatic range sums in
Difference arraymany range adds, one final read
Monotonic stacknext/previous greater or smaller
Monotonic queuesliding window min/max
Minimum stack/queueminimum under arbitrary push/pop

Range query

StructureWhen
Sparse tablestatic, idempotent op, query
Disjoint sparse tablestatic, any associative op, query
Fenwick treepoint update, prefix sum; shortest code
Segment treeany associative op with updates
Lazy segment treerange updates too
Segment tree beatschmin/chmax range updates
Sqrt decompositionoperations a segment tree cannot merge
Merge sort treecount elements in a range, no updates
Wavelet treerange -th smallest in bits
Li Chao treeminimum over a set of lines at a point
2D BIT / segment treegrid queries on a dense small grid

Sets and priority

StructureWhen
Binary heapalways need the minimum; Dijkstra
Meldable heapsmerging heaps cheaply
Balanced BST (set/map)ordered, predecessor/successor
PBDS `tree`-th smallest and rank
Treapa BST you need to extend
Implicit treapinsert/erase/reverse inside a sequence

Disjoint sets

StructureWhen
DSUmerging only; components, Kruskal
Rollback DSUoffline dynamic connectivity
Parity DSUbipartiteness, relative constraints

Trees

StructureWhen
Binary liftingLCA, -th ancestor, path aggregates (no updates)
Euler tour + BITsubtree queries and updates
HLDpath queries and updates on a static tree
Centroid decompositioncounting over all paths
Virtual treemany queries over small vertex subsets
DSU on treeoffline subtree aggregate queries
Link-cut treeonline link/cut with path queries
Euler tour treeonline link/cut with subtree queries

Strings and bits

StructureWhen
Trieprefix queries, autocomplete
Binary triemaximum XOR with a query value
XOR basismaximum XOR over all subsets
Suffix array + LCPsubstring queries, low memory
Suffix automatonall substrings, online, 30 lines
Eertreeall palindromic substrings
Aho-Corasickmany patterns at once
bitsetboolean DP, set operations, speedup

Persistence and geometry

StructureWhen
Persistent segment treerange -th, historical versions
KD-treenearest neighbour, online geometric queries
Quadtree / R-tree / BVHspatial data with extent

Exotic

StructureWhen
van Emde Boas, y-fast triepredecessor in
Fusion treeword-RAM predecessor search
Soft heap ops with bounded corruption

The decision tree

Do the queries involve ranges of an array?
├─ no updates, idempotent op   -> sparse table
├─ no updates, k-th smallest   -> persistent segtree / wavelet tree
├─ point update, prefix sum    -> Fenwick tree
├─ range update, range query   -> lazy segment tree
├─ chmin/chmax updates         -> segment tree beats
├─ weird un-mergeable op       -> sqrt decomposition
└─ offline                     -> Mo's algorithm, or a BIT sweep

Do they involve a tree?
├─ subtree                     -> Euler tour + BIT
├─ path, static tree           -> HLD (or binary lifting if read-only)
├─ all paths, counting         -> centroid decomposition
├─ small vertex subsets        -> virtual tree
└─ tree changes online         -> link-cut tree

Sets that merge?              -> DSU (rollback if you need undo)
Need the k-th smallest?        -> PBDS, or a BIT over values
Maximum XOR?                   -> binary trie (element) / XOR basis (subset)
Strings?                       -> suffix automaton, or hashing

See also: Data Structures · Range Query Techniques · Complexity Cheatsheet