Can you help me how to write recursive code of replacement

I m not getting how to write a recursive code of replacement sum.

@parasjain011999
Hello Paras ,
The idea is to use following BST property. If we do reverse Inorder traversal of BST, we get all nodes in decreasing order. We do reverse Inorder traversal and keep track of the sum of all nodes visited so far, we add this sum to every node.
a) call(root->right,sum)
b) sum+=root->data
c) root->data=sum
d) call(root->left,sum)

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.