# Segment Tree Query

Segment tree query illustration

## Explaining how it operates

Generally, a segment tree's nodes would contain elements that are comparable, which contain the absolute max/min of its children.
The algorithm operates by requiring the max/min or a range.
It starts on the root and splits into a right search and/or a left search recursively until it reaches either cases:

- Case 1: The range is covered entirely, therefore return the current node' value
- Case 2: The range is invalid, return an appropriate value
- Case 3: The range is partly on the right and left, then return the max/min of the call to the right and left subtrees

If you want to learn more about it, here is a good source.