Lazy Propagation for Range Updates
Defer updates over whole ranges.
The Range Update Problem
What if a query says add 5 to every element from l to r? Touching each leaf is O(n) per update, far too slow for many range updates. 😰
The Lazy Idea
Lazy propagation lets a node remember a pending change without pushing it to children yet. Work is deferred until you actually need those children.
All lessons in this course
- Fenwick Tree for Prefix Sums
- Inversions with a BIT
- Segment Tree: Build & Query
- Lazy Propagation for Range Updates