Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Public Member Functions | |
FenwickTree (const std::vector< int > &arr) | |
FenwickTree (int x) | |
void | update (int id, int val) |
int | sum (int id) |
int | sum_range (int l, int r) |
Private Member Functions | |
int | offset (int x) |
Private Attributes | |
int | n |
std::vector< int > | bit |
n --> No. of elements present in input array. bit[0..n] --> Array that represents Binary Indexed Tree.
|
inlineexplicit |
|
inlineexplicit |
Constructor
[in] | x | --> Size of array that represents Binary Indexed Tree. |
|
inlineprivate |
Returns the highest power of two which is not more than x
|
inline |
Get prefix sum upto id
|
inline |
Returns the prefix sum in range from l to r
|
inline |
Add val at id