MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / getSum

Function getSum

CPP/Segment Tree/basic.cpp:25–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25int getSum(vector<int> &tree, int L, int R, int si, int ei, int idx)
26{
27 if (ei < L || si > R)
28 {
29 return 0;
30 }
31
32 if (L <= si && R >= ei)
33 {
34 return tree[idx];
35 }
36
37 int mid = si + ((ei - si) / 2);
38
39 return getSum(tree, L, R, si, mid, (2 * idx) + 1) + getSum(tree, L, R, mid + 1, ei, (2 * idx) + 2);
40}
41
42int getSum(vector<int> &nums, vector<int> &tree, int L, int R)
43{

Callers 1

mainFunction · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected