Fenwick Tree
A Fenwick Tree, or Binary Indexed Tree, is a compact structure for maintaining prefix aggregates and supporting point updates efficiently. It uses the binary representation of indices to store partial sums. For an array of n elements, point updates and prefix-sum queries both take O(log n), while memory usage is O(n).
Point update: O(log n).
Prefix query: O(log n).
Range sum: O(log n) using two prefix queries.
Space: O(n).
Simpler and often more memory-efficient than a Segment Tree for suitable operations.
It is primarily suited to operations with an invertible prefix aggregation such as sum.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience