#include <bits/stdc++.h>
using namespace std;
int SegmentTree(int ss, int se, int si, int arr[], int &tree[]) {
if (ss == se) {
tree[si] = arr[ss];
return arr[ss];
}
int mid = (ss + se) / 2;
tree[si] = SegmentTree(ss, mid, ((2 * si) + 1), arr, tree) +
SegmentTree(mid + 1, se, ((2 * si) + 2), arr, tree);
return tree[si];
}
int main() {
int n;
cout << "Enter the size of the array: ";
cin >> n;
int arr[n];
cout << "Enter the elements of the array: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
cout << "Our input array is:\n";
for (int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
int tree[(4 * n)] = {0};
cout << "\nOur output Segment tree for this array would be:\n";
SegmentTree(0, n - 1, 0, arr, tree);
for (int i = 0; i < (4 * n); i++) {
cout << arr[i] << " ";
}
return 0;
}
Following are the errors: 'ss' was not declared in this scope 'se' was not declared in this scope 'tree' was not declared in this scope 'si' was not declared in this scope Please help me to find out what is wrong with this code. I'm not getting it. I use to write functions like this before and they use to work. But now it is not working.