The constructor initializes an array with a specified length and fills it with zeros.
The parameter n
represents the size of the array that will be used to store the sum tree. The
sum tree is a binary tree data structure used to efficiently calculate the sum of a range of elements in an array.
The size of the sum tree array is n + 1
because
Private
_sumProtected
_setThe function calculates the prefix sum of an array using a binary indexed tree.
The parameter "i" in the function "getPrefixSum" represents the index of the element in the array for which we want to calculate the prefix sum.
The function getPrefixSum
returns the prefix sum of the elements in the binary indexed tree up to index
i
.
The function getRangeSum
calculates the sum of a range of numbers in an array.
The start parameter is the starting index of the range for which we want to calculate the sum.
The "end" parameter represents the ending index of the range for which we want to calculate the sum.
the sum of the elements in the range specified by the start and end indices.
The update function updates the values in a binary indexed tree by adding a delta value to the specified index and its ancestors.
The parameter i
represents the index of the element in the _sumTree
array that needs to be
updated.
The "delta" parameter represents the change in value that needs to be added to the element at index "i" in the "_sumTree" array.
Static
lowGenerated using TypeDoc
data-structure-typed
Author
Tyler Zeng
Copyright
Copyright (c) 2022 Tyler Zeng zrwusa@gmail.com
License
MIT License