FenwickTree class
A Binary Indexed Tree over num supporting point updates and range sums.
Constructors
- FenwickTree(int size)
-
Creates a tree of
sizeelements, all initialized to zero. Requiressize >= 0. Audited: 2026-06-12 11:26 EDT -
FenwickTree.fromList(List<
num> values) -
Creates a tree seeded with
values, inO(n). Audited: 2026-06-12 11:26 EDT
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prefixSum(
int index) → num -
Sum of elements
[0..index]inclusive (0-based), inO(log n). Requires0 <= index < length. Audited: 2026-06-12 11:26 EDT -
rangeSum(
int low, int high) → num -
Sum of elements
[low..high]inclusive (0-based), inO(log n). Requires0 <= low <= high < length. -
toString(
) → String -
A string representation of this object.
override
-
update(
int index, num delta) → void -
Adds
deltato the element atindex(0-based), inO(log n). Requires0 <= index < length. -
valueAt(
int index) → num -
The current value at
index(0-based), inO(log n). Requires0 <= index < length. Audited: 2026-06-12 11:26 EDT
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited