Skip to content

Commit 291665d

Browse files
authored
Fix segment indices in segment tree documentation
Corrected the segment indices in the explanation of the segment tree structure.
1 parent 6baac9a commit 291665d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/data_structures/segment_tree.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ And precomputed prefix sums can compute sum queries in $O(1)$, but updating an a
3434

3535
We can take a divide-and-conquer approach when it comes to array segments.
3636
We compute and store the sum of the elements of the whole array, i.e. the sum of the segment $a[0 \dots n-1]$.
37-
We then split the array into two halves $a[0 \dots n/2-1]$ and $a[n/2 \dots n-1]$ and compute the sum of each halve and store them.
37+
We then split the array into two halves $a[0 \dots (n-1)/2]$ and $a[(n+1)/2 \dots n-1]$ and compute the sum of each halve and store them.
3838
Each of these two halves in turn are split in half, and so on until all segments reach size $1$.
3939

4040
We can view these segments as forming a binary tree:

0 commit comments

Comments
 (0)