Do we actually need lazy propagation on segment trees? There seems to be a lot of encouragement for new people to learn segment trees, and in particular the lazy propagation technique, and it seems to me that most of the time it is not actually needed.
As a quick refresher (although I feel most of you would already know), lazy propagation is a technique in segment trees that lets you do updates on whole ranges of elements, by first only updating the smallest factoring of the update range in the tree. For example, in order to update range $[2, 5]$, what you do is you update only ranges $[2, 2], [3, 4], [5, 5]$ in the segment tree, and next time node $[3, 4]$ is accessed you "propagate" the updates downward into ranges $[3, 3]$ and $[4, 4]$. This allows you to effectively aggregate (combine) multiple updates on a given range, to save extra work.
Usually when people talk about lazy propagation, some tasks like "add on range" — "minimum on range" or "add on range" — "sum of range" naturally come to mind. However, I feel lik...
Do we actually need lazy propagation on segment trees?, I've encountered need some sort of "lazy" value that holds an aggregate of
operations that affect the, comparison if people are interested, but from my experience I found that lazy
propagation yields a, operations inside $lazy$ while going down in the tree. The technique is
similar to something called, the lazy propagation technique, and it seems to me that most of the time it is
not actually needed, why any of these kind of problems would use lazy propagation instead of this
technique., ### So, you still store lazy array, but you just don't propagate. Why should we
care?, An alternative way one could approach these kind of problems is to keep an
extra array $lazy$ with, As a quick refresher (although I feel most of you would already know), lazy
propagation is a, Usually when people talk about lazy propagation, some tasks like "add on range"
— "minimum on
Полный текст и комментарии »