Segment Tree Persistency on Lazy Updates Part 1
Segment Tree Persistency on Lazy Updates Part 1
Introduction
A persistent segment tree is a segment tree where old versions do not disappear. After an update, we create a new version of the array, but all previous versions are still available for queries.
In a normal persistent segment tree, students usually first see point updates. We clone only the nodes on the path from the root to one leaf, and all other nodes are shared between versions.
In this lecture, we go one step further: range updates with lazy propagation. This is useful when we need queries like:
- create a new version after adding to every element in ;
- ask the sum on in any old version.
The important idea is that persistence and lazy propagation can work together, but we must be careful: we are not allowed to modify nodes that belong to old versions.
Problem or motivation
We have an array . Version is the initial array.