Point updates and repeated interval queries. Work through the operation contract, runnable case, and cost before selecting the structure for a real workload.
Lessons
- Fenwick trees: update points and query prefix totals
- Segment trees: combine child ranges after updates
Practice and next steps
- Project: choose structures for a dispatch board
- Project: audit depot connectivity and daily ranges
- Linear and hash structure decisions
- Tree, graph, and range structure decisions
- DSA Tutorial
Sparse tables: precompute immutable range minima
Persistent segment trees: retain old range-sum versions
Sparse coordinate segment tree: allocate only visited paths
Lazy segment tree: add to a range and query its minimum
Two-dimensional Fenwick tree: update cells and sum rectangles
Two Fenwick trees: add across ranges and query sums
Square-root blocks: update one capacity and sum a range
Merge-sort trees: count readings below a threshold in one interval
Disjoint sparse tables: immutable sums with constant-time queries
Li Chao trees: minimum linear tariff at a chosen quantity
Coordinate compression: preserve order with dense integer ranks
Fenwick frequency index: select the kth stored key
Mo ordering: count distinct scan codes across an offline query batch
Two-dimensional prefixes: constant-time static rectangle sums
Segment tree beats: cap a range while retaining its sum
Wavelet matrices: count frequencies and find subarray quantiles
Compressed 2D Fenwick trees: toggle known points and count rectangles
Segment-tree stabbing indexes: list intervals active at one point
Two-dimensional segment trees: correct sensors and sum rectangles
Range-majority indexes: verify a candidate before returning it
Range-mode indexes: combine complete-block modes with fringe candidates
Persistent range MEX: search last occurrences in prefix versions
Range XOR bases: merge linear spans in a segment tree
Affine lazy segment trees: compose range calibration before summing
Persistent subarray ranks: subtract prefix frequency trees
Maximum-subarray segment trees: preserve the crossing burst
Li Chao interval offers: limit each line to its valid minutes
Persistent range-distinct counts: keep only the latest position active
Editable substring fingerprints: join hashes in a segment tree
