update in BIT

Revision en2, by t3rminated, 2016-12-20 10:14:44

If i have an update condition like if i want to assign all elements in range (l,r) with a value x(x!=0) and i have many updates like this , for example —

l r x

1 4 2

3 4 3

7 8 9

now if i want to query for an index y , then can i do this using BIT? I have come up with this solution but it isn't working —

update(l, x)

update(r+1, 0) #0 means index still unassigned.

now if i query for like index 4(read(4) — read(4-1)) i am not getting the correct answer. Is my approach correct ?

Tags bit

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English t3rminated 2016-12-20 10:14:44 31
en1 English t3rminated 2016-12-20 10:12:29 538 Initial revision (published)