Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. int read(int idx){
  2.     int sum = 0;
  3.     while (idx <= MaxVal){
  4.         sum += tree[idx];
  5.         idx += (idx & -idx);
  6.     }
  7.     return sum;
  8. }
  9.  
  10. void update(int idx ,int val){
  11.     while (idx > 0){
  12.         tree[idx] += val;
  13.         idx -= (idx & -idx);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement