Fenwick Tree Algorithm

When compared with a flat array of numbers, the Fenwick tree achieves a much better balance between two operations: component update and prefix sum calculation. A Fenwick tree or binary indexed tree is a data structure that can efficiently update components and calculate prefix sums in a table of numbers.

Fenwick Tree source code, pseudocode and analysis