June 24th, 2013, 06:03 AM
Segment Tree - operation of =
I'm trying to write segment tree with operation of (=) - When in comes to insert([a,b],c) all of element from interval [a,b] will be equal to c.
As for query(a,b) it will be sum of elements from interval [a,b].
Look at example:
insert(1, 5, 11)
Elements from interval [1,5] are equal to 11.
query(0,100) return value 5*11 = 55.
Let's look at query(0,100) - it is 2*11 + 4*2 = 22+8=30.
As we see, two elements have new value 11 -> 2.
I can write segment tree with insert (sum - not replace). and query(sum, like in case described by me).
Click Here to Expand Forum to Full Width