0PricingLogin
Competitive Programming Academy · Lesson

Fenwick Tree for Prefix Sums

Point update, prefix query in log n.

Why Prefix Arrays Break

A plain prefix-sum array answers ranges instantly, but a single update forces you to rebuild it. With many updates, that gets slow. ⏱️

Enter the Fenwick Tree

The Fenwick tree, or BIT, supports both point updates and prefix queries in O(log n). It is your go-to for dynamic running totals.

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