Is there any ways we can update Binary Index Tree when it's a min/max tree?
For example, I have an array:
10 4 5 6 8
tree.getMin(3) = 4; //query at index 3 the result is 4
tree.update(2, 1); //update value at index 2 from 5 to 1
tree.getMin(3) = 1; //requery at index 3 we have the new result is 1
Thanks!!
For this case there is another data structure.
This seem incorrect, I try this test:
similar to basic BIT:
I don't think your tree will work on the following case:
However, on the last query your tree will return 5.
You are right.
It works only when all elements don't increase (or don't decrease if it's a max-BIT).