Segment tree:Doubt in implementation program.

I am reading this hackerearth note on segment tree and I am having a minor doubt.

They have defined a node structre with variables offt and cmax. What are the roles of these two variables ?

Hi shubham99,

segment tree code is given above but this code is segment tree with lazy propagation which is another efficient method for range query

by the way “offt” is the total increment which has to be done with child node of current node. because in lazy propagation we update when we need it save much time that’s why it is more efficient than segment tree.

and “cmax” is the maximum number in subtree of current node.

every node of tree has these two attribute.

go and learn lazy propagation it’s fun :slight_smile: