Tree Visualization
Initialize the Binary Indexed Tree to see visualization
(Array indices start from 1 for BIT implementation)
STEM Interactive Visual Learning Program at TEC-Bridge AI
(Array indices start from 1 for BIT implementation)
Binary Indexed Tree (Fenwick Tree) is a data structure that efficiently supports prefix sum queries and updates in O(log n) time.
Key Properties:
BIT stands for Binary Indexed Tree, also known as Fenwick Tree after Peter Fenwick who invented it in 1994.
Query Sum calculates the prefix sum from index 1 to a given index, efficiently traversing parent nodes in the BIT structure.
Range Query finds the sum of elements between two indices using the formula: sum(left, right) = prefixSum(right) - prefixSum(left-1).
Strengths:
Limitations:
| Operation | Time Complexity | Space Complexity |
|---|---|---|
| Initialize | O(n log n) | O(n) |
| Update | O(log n) | O(1) |
| Query Sum | O(log n) | O(1) |
| Range Query | O(log n) | O(1) |