segment tree implimentation

void seg_ment(int node,int b,int e){
if(b==e){
segment_tree[node]=A[b];
}
else{
int left=2node,right=2node+1;
seg_ment(left,b,(b+e)/2);
seg_ment(right,(b+e)/2 +1,e);
int lcontent=segment_tree,rcontent=segment_tree[right];
segment_tree[node]=lcontent+rcontent;
printf("%d ",segment_tree[node]);
}
}

if any error plz tell me

1 Like

First of all, what are you trying to do with segment tree?

RMQ

Sum of given range

It’s absolutely fine.

You can read a tutorial on Segment Trees here

@tyrant he is building the segment tree for given array A.

//