(int l, int r)
| 53 | |
| 54 | // this is responsible for the sum betweeen given ranges |
| 55 | public int sumRange(int l, int r) { |
| 56 | // get leaf with value 'l' |
| 57 | l += n; |
| 58 | // get leaf with value 'r' |
| 59 | r += n; |
| 60 | int sum = 0; |
| 61 | while (l <= r) { |
| 62 | if ((l % 2) == 1) { |
| 63 | sum += tree[l]; |
| 64 | l++; |
| 65 | } |
| 66 | if ((r % 2) == 0) { |
| 67 | sum += tree[r]; |
| 68 | r--; |
| 69 | } |
| 70 | l /= 2; |
| 71 | r /= 2; |
| 72 | } |
| 73 | return sum; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | } |
nothing calls this directly
no outgoing calls
no test coverage detected