Skip to content

Commit eac2bb3

Browse files
committed
Fix typos
1 parent d4e1bf3 commit eac2bb3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/data_structures/segment_tree.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,11 @@ These values can be computed in parallel to the merging step when we build the t
653653

654654
How does this speed up the queries?
655655

656-
Remember, in the normal solution we did a binary search in ever node.
656+
Remember, in the normal solution we did a binary search in every node.
657657
But with this modification, we can avoid all except one.
658658

659-
To answer a query, we simply to a binary search in the root node.
660-
This gives as the smallest element $y \ge x$ in the complete array, but it also gives us two positions.
659+
To answer a query, we simply do a binary search in the root node.
660+
This gives us the smallest element $y \ge x$ in the complete array, but it also gives us two positions.
661661
The index of the smallest element greater or equal $x$ in the left subtree, and the index of the smallest element $y$ in the right subtree. Notice that $\ge y$ is the same as $\ge x$, since our array doesn't contain any elements between $x$ and $y$.
662662
In the normal Merge Sort Tree solution we would compute these indices via binary search, but with the help of the precomputed values we can just look them up in $O(1)$.
663663
And we can repeat that until we visited all nodes that cover our query interval.
@@ -755,7 +755,7 @@ But before we do this, we must first sort out the root vertex first.
755755
The subtlety here is that the right half of the array should still be assigned to the value of the first query, and at the moment there is no information for the right half stored.
756756
757757
The way to solve this is to push the information of the root to its children, i.e. if the root of the tree was assigned with any number, then we assign the left and the right child vertices with this number and remove the mark of the root.
758-
After that, we can assign the left child with the new value, without loosing any necessary information.
758+
After that, we can assign the left child with the new value, without losing any necessary information.
759759
760760
Summarizing we get:
761761
for any queries (a modification or reading query) during the descent along the tree we should always push information from the current vertex into both of its children.

0 commit comments

Comments
 (0)