A C implementation of Fenwick trees. The Fenwick tree is a great data structure for handling operations on prefixes of sequences. This particular version implements prefix sums ans updates. Both operations take O(lg N)
time in the worst case where N
is the length of the sequence.
inc(pos, delta)
: increment prefix [1..pos] of sequence by deltaget(pos)
: get sum of prefix [1..pos] of sequence