Binary tree sum replacements

here , as per the solution by sir…we are making the changes in the original tree…but why didn’t we use pass by refrence here…?

Hi @ynikhil1999
We make a binary tree using pointers and work on it through pointers only.
Pointers are special type of variables that store memory locations. When we pass a pointer to a function , even though the pointer itself is passed by value , any changes made to the node or the values at the memory location it is pointing to are reflected back in the calling function as well .
That is , even though the pointer itself is passed by value , you can say that its memory is passed by reference.
Which is why this approach works.

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.