Skip to content

Commit

Permalink
Update fenwick_tree_2d.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrch authored Oct 9, 2020
1 parent 644fb68 commit 7f94ce3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions range_queries/fenwick_tree_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
#include <cassert>
#include <vector>

using namespace std;

template <class T>
struct fenwick {
int siz;
vector<T> arr;
std::vector<T> arr;

// Constructor
// n - size of the array on which fenwick tree is used
// creates a new array with all entries as 0
// indicies are 1-indexed
fenwick(int n) {
explicit fenwick(int n) {
siz = n;
arr.resize(n + 1);
}
Expand Down Expand Up @@ -49,13 +48,13 @@ template<class T>
struct fenwick2D{

int siz;
vector<fenwick<T>> arr;
std::vector<fenwick<T>> arr;

// Constructor
// n - size of the array on which fenwick tree is used
// creates a new array of fenwick trees of size n with all entries 0
// indicies are 1-indexed
fenwick2D(int n) {
explicit fenwick2D(int n) {
siz = n;
arr.resize(n + 1, fenwick<T>(n));
}
Expand Down Expand Up @@ -112,7 +111,7 @@ int main() {
assert(fenwick_tree_2D.query(1, 1, 2, 2) == 9);
assert(fenwick_tree_2D.query(1, 2, 3, 3) == 27);

cout << "All Test Passed\n";
std::cout << "All Test Passed\n";

return 0;
}

0 comments on commit 7f94ce3

Please sign in to comment.