Hard

Fenwick Tree

A Fenwick tree, or binary indexed tree, stores partial prefix sums. Adding a value and reading a prefix both follow the binary representation of the index.

Costs

CategoryData Structure
DifficultyHard
Point updateO(log n)
Prefix sumO(log n)
Build from an arrayO(n log n), or O(n) with a careful fill

Questions

What is Fenwick Tree?

A Fenwick tree, or binary indexed tree, stores partial prefix sums. Adding a value and reading a prefix both follow the binary representation of the index.

Where do I practice it?

DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.