at 14:50 why are we taking 2index for left side and 2index+1 for the right side
Segment Trees Basics - Range Minimum Query
Because for a binary tree
4
/ \
2 3
lets start putting the value in an array [1 indexed] 4 is put at arr[1] then left child is put at arr[2] ie parent_index2 , and 3 is put at arr[3] ie parent_index2 + 1 , since val = 4 is parent and parent_index = 1
so for left child is put at 2parent_index
right child at 2parent_index+1
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.