An array of numbers that will be used to build a binary search tree.
Optional
start: numberThe start
parameter is the index of the first element in the values
array that should
be included in the range. If no value is provided for start
, it defaults to 0, which means the range starts from
the beginning of the array.
Optional
end: numberThe "end" parameter is the index of the last element in the "values" array that should be included in the range. If not provided, it defaults to the index of the last element in the "values" array.
Private
_endPrivate
_rootPrivate
_startPrivate
_valuesProtected
_setProtected
_setProtected
_setProtected
_setThe function builds a segment tree by recursively dividing the given range into smaller segments and creating nodes for each segment.
The start
parameter represents the starting index of the segment or range for which we are
building the segment tree.
The end
parameter represents the ending index of the segment or range for which we are
building the segment tree.
a SegmentTreeNode object.
The function querySumByRange
calculates the sum of values within a given range in a segment tree.
The starting index of the range for which you want to calculate the sum.
The parameter indexB
represents the ending index of the range for which you want to
calculate the sum.
The function querySumByRange
returns a number.
The function updates the value of a node in a segment tree and recalculates the sum of its children if they exist.
The index parameter represents the index of the node in the segment tree that needs to be updated.
The sum
parameter represents the new value that should be assigned to the sum
property of
the SegmentTreeNode
at the specified index
.
Optional
val: numberThe val
parameter is an optional value that can be assigned to the val
property of the SegmentTreeNode
object. It is not currently used in the code, but you can uncomment the line // cur.val = val;
and pass a value for val
in the
The function does not return anything.
Generated using TypeDoc
The constructor initializes the values, start, end, and root properties of an object.