int sum_replacement(node*root)
{
if(root==NULL)
return 0;
else if(root->right==NULL and root->left==NULL)
return root->data;
// recursive part
int leftsum=sum_replacement(root->left);
int rightsum=sum_replacement(root->right);
int temp=root->data;
root->data=leftsum+rightsum;
return temp+leftsum+rightsum;
}
i this sum_replacement function, what is work of leftsum and rightsum and how they are working, please explain me i detail.