Data Structures¶
Core
This area is for reusable tools that turn repeated work into fast queries, updates, merges, or ordered-set operations.
The Main Choice In This Area¶
Most data-structure mistakes come from reaching for something heavier than the invariant actually needs.
- if the state is just connected components, start with
DSU - if the state is prefix-style aggregation, start with
Fenwick Tree - if the state needs general segment decomposition, move to
Segment Tree - if the real invariant is monotone boundaries or sliding extrema, use
Monotonic Stack / Queue - if the real state is one ordered set with rank or predecessor logic, move toward
PBDS,treap, orsplay
Use This Area When¶
- recomputing from scratch is clearly too slow
- the real state is one array, set, component partition, or interval family
- you need to choose between lighter and heavier query/update tools on purpose
Start With One Route¶
| If your bottleneck is... | Open first | Then |
|---|---|---|
| connectivity and components | DSU | Fenwick Tree or Segment Tree |
| range sums and point updates | Fenwick Tree | Segment Tree, then Lazy Segment Tree |
| monotone scans and sliding extrema | Monotonic Stack / Queue | the corresponding ladder and one nearest-boundary anchor |
rank, k-th, or ordered-set surgery |
PBDS / Order Statistics Tree | Treap / Implicit Treap, then Splay Tree if needed |
Core Progression¶
Core first- DSU
- Fenwick Tree
- Segment Tree
- Monotonic Stack / Queue
-
Heaps and Ordered Sets
-
Then add - Lazy Segment Tree / Sparse Table
- PBDS / Order Statistics Tree
- Binary Trie / XOR Queries
-
Offline Tricks / Mo's Algorithm
-
Deep later - DSU Rollback / DSU On Tree
- Treap / Persistent Treap / Persistent Data Structures
- Wavelet Tree / Segment Tree Beats / ODT
- Interval Trees / Pairing-Leftist Heap / Splay Tree
- B-Trees / Skip Lists / X-Fast / Y-Fast Tries as textbook breadth
Good First Repo Anchors¶
- CVP00001
- Nearest Smaller Values
- ORDERSET
- Salary Queries
- Powerful Array
- Willem, Chtholly and Seniorious
Browse All Subtopics¶
- DSU
- DSU Rollback / Offline Dynamic Connectivity
- DSU On Tree / Small-To-Large
- Fenwick Tree
- Monotonic Stack / Queue
- Binary Trie / XOR Queries
- PBDS / Order Statistics Tree
- Balanced BSTs For Contests
- B-Trees
- Skip Lists
- X-Fast / Y-Fast Tries
- Interval Trees
- Splay Tree
- Pairing Heap / Leftist Heap
- Persistent Data Structures
- Persistent Treap
- Treap / Implicit Treap
- Wavelet Tree
- Mo's Algorithm
- Segment Tree
- Lazy Segment Tree
- Segment Tree Beats
- ODT / Chtholly
- Sparse Table
- Heaps And Ordered Sets
- Offline Tricks
Go Deeper¶
- Course: Princeton COS 226
- Course: MIT 6.1210 / 6.1220
- Reference: USACO Guide
- Reference: KACTL