0Pricing
Competitive Programming Academy · Lesson

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

  1. Fenwick Tree for Prefix Sums
  2. Inversions with a BIT
  3. Segment Tree: Build & Query
  4. Lazy Propagation for Range Updates
← Back to Competitive Programming Academy