Getting wrong answer please explain why
if it is one based indexing then why do i need to subtract 1 , i dont get the logic exactly also it isn’t working when i submit it
could you explain alittle more why -1
check now
in ur array u are storing elements from index 0 onwards and in the query they are giving index by assumng that element are stored from index 1 onwards.
so that is the reason why we are subtracting 1 from the given index
hey, this else if(x==2){ int inc=z-arr[y-1];//incremnt arr[y-1]=z; pointupdate(tree,inc,y-1,1,0,n-1);//again y-1 }
else if(x==2){ int inc=z-arr[y-1];//incremnt arr[y-1]=z; pointupdate(tree,inc,y-1,1,0,n-1);//again y-1 } why is it necessary to do i mean none of the lectures showed to do this before incrementing nodes
in the second type of query u are given final updated value but ur point update function takes increment value .
so that is the reason we are getting differnt between present array value and desired value and then updating that change in the tree.
and since we are not updating array in our update function it is need to do it inside the else itself
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.