Hi everyone, I'm currently studying BIT on Cp-Algorithms and got confused on the range updates and range queries part. So basically I saw them using a method that's relatively easy to understand to solve range updates and point queries, but suddenly change to another more confusing method to calculate range updates and range queries.
but later on they change to use ...
so my question is pretty obvious : If I can calculate point queries ( the point_query
function from range updates and point queries method) for both the l-1 and r point, why bother changing the method ?
I'm well aware that this question occurred mean I've not fully understand BIT yet. Please answer my question if you can. Thank you for your time !!!
Link to the original code in case you want more details : link
Dunno why all the downvoting, the person even added comments to the code excerpts to remove ambiguous details for us.
Alex_Miller I didn't read into the details of how their 2-BIT approach works, so perhaps I'm not understanding the full extent of your question — but could you describe in detail how you plan to use the "point-query, range-update" approach to solve "range-query, range-update"? Getting the value at point R and subtracting the value at point L-1 does not give you sum(L..R), it just gives you a meaningless subtraction of two elements.