Fenwick Tree (Binary Indexed Tree)

Data structure for efficient prefix sum calculations and updates.

A Fenwick tree, also known as a binary indexed tree (BIT), is a data structure used to efficiently calculate prefix sums in an array and update elements. It allows for point updates (changing a single element's value) and range queries (summing a contiguous segment of the array) in logarithmic time complexity (O(log n)). It’s particularly useful when dealing with frequent updates and queries on large arrays.

Built by Tim Jones