Competitive Programing Problem Solutions/Graph Theory/Binary Indexed Tree/Basic Code/Binary Indexed Tree.cpp
int *constructBITree(int arr[], int n){
    int *BITree = new int[n+1];
    for (int i=1; i<=n; i++)
        BITree[i] = 0;/// Create and initialize BITree[] as 0
    for (int i=0; i<n; i++)
        updateBIT(BITree, n, i, arr[i]);/// Store the actual values in BITree[] using update()

    // Uncomment below lines to see contents of BITree[]
    //for (int i=1; i<=n; i++)
    //      cout << BITree[i] << " ";

    return BITree;
}
/// Constructs and returns a Binary Indexed Tree for given array of size n.

Constructs and returns a Binary Indexed Tree for given array of size n.
Constructs and returns a Binary Indexed Tree for given array of size n .
int *constructBITree(int arr[], int n){
    int *BITree = new int[n+1];
    for (int i=1; i<=n; i++)
        BITree[i] = 0;
    for (int i=0; i<n; i++)
        updateBIT(BITree, n, i, arr[i]);
    return BITree;
}
int * constructBITree ( int arr [ ] , int n ) { int * BITree = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) BITree [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) updateBIT ( BITree , n , i , arr [ i ] ) ; return BITree ; }
Constructs and returns a Binary Indexed Tree for given array of size n.
Constructs and returns a Binary Indexed Tree for given array of size n .
/// Create and initialize BITree[] as 0
 /// Store the actual values in BITree[] using update()
 // Uncomment below lines to see contents of BITree[]
 //for (int i=1; i<=n; i++)
 //      cout << BITree[i] << " ";
