Query bits , what to store in segment tree?

ham number of 1s store karvayge har node k correspoding???

integer vala part samjh nhi aaya mujhe ki left shift kyu kiya hai ?? mtlb mei visualize nhi kar paari ki ans kaise aaygah

@Muskan-Gupta-598128740703036 we will be storing the number formed so far in the bits(coming under that node).


Here is code you may refer it.
If this resolves your doubt mark it resolved.

@Muskan-Gupta-598128740703036 i guess you are asking how are we merging two nodes?
suppose node x represents node for bits from 1 to 3 position, y represents node for bits 4-5 position, now both of them merge to form z (parent) x is left node , y is right node.
Now lets starting thinking in reverse direction, suppose we have number a binary number 10101 (21) now splitting it about 3rd bit we will have 101, and 01. now to remove last two bits to get 101 we will need to perform right shift on the number 10101. Now what we are actually doing opposite of this(we are merging to numbers instead of splitting) so we perform first left shift to the left child (to create space for the right child) and then add right child.
If this resolves your doubt mark it as resolved.

sir ham direct string ki form mei store na karva le??? bs jabh integer return krna hoga toh string ko decimal m convert kar lege ???

If we store it in form of string we will face problem in updation and query, as we will need to go through the string every time resulting in increased complexity.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.