An array of numbers that will be used to build a binary search tree.
Optionalstart: 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.
Optionalend: 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.
The function returns the value of the protected variable _end.
The value of the protected property _end.
The function returns the root node of a segment tree.
The root property of the class SegmentTreeNode or undefined if it is not defined.
The function returns the value of the protected variable _start.
The start value, which is of type number.
The function returns an array of numbers.
An array of numbers is being returned.
The build function creates a segment tree by recursively dividing the given range into smaller segments and assigning the sum of values to 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 want to build a 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.
Optionalvalue: numberThe value parameter is an optional value that can be assigned to the value
property of the SegmentTreeNode object. It is not currently used in the code, but you can uncomment the line // cur.value = value; and pass a value for value in the
The function does not return anything.
The constructor initializes the values, start, end, and root properties of an object.