Apex › Storage & databases

Fenwick tree (Binary Indexed Tree)

Prefix sums and point updates both in O(log n) via one binary trick. Watch each tree node cover a block sized by its lowest set bit, and the query/update paths light up the ~log n nodes they touch.

More in Storage & databases