Practice Discrete Math

Algorithms / Fenwick Tree Point Update

Least You Need to Know: Fenwick Point Updates, Frequencies, and Order Statistics

Point updates in a Fenwick tree climb upward through the indices whose stored partial sums include the changed position. This makes the structure especially useful for dynamic frequency tables and coordinate-compressed counting problems.

The least you need to know

Key notation

add(i, delta) increase position i by delta
i += lowbit(i) move to the next Fenwick cell covering the point
freq prefix count of compressed values up to a rank

Tiny worked example

  • If index 6 increases by 1, update tree cells whose represented ranges contain position 6.
  • In 1-based Fenwick code, repeatedly add the low bit: `6 -> 8 -> 16 ...`.
  • Each visited cell stores a partial sum that now needs the same delta.
  • Only logarithmically many cells change.

Common mistakes

How to recognize this kind of problem

Start practice