Hello everyone,I have just learnt segment tree(range sum and range min/max).I tried first segment tree question which is this.But I am getting what value should I assign to the parents while building the tree.I know What to assign to leaf nodes but not getting to the parent.Here I am facing problem
void build(string &s,int pos,int low,int high)
{
if(low==high)
{
tree[pos]=s[low]-'0';
return;
}
int mid=(low+high)/2;
build(s,2*pos,low,mid);
build(s,2*pos+1,mid+1,high);
tree[pos]= //Here ?? What should be in this place
}