Segment Tree Query and Update
A query takes whole nodes inside the range and splits only the ones on its edge.
Segment Tree: Sum of indices 2 to 5
Node 1 covers indices 0 to 7, holding 36. That straddles the edge, so split into both children.
Cost
- Best
- O(log n)
- Average
- O(log n)
- Worst
- O(log n)
- Space
- O(n)
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
Segment Tree covers these too, in the same run.