int sum(struct node* root) { if(root == NULL) return 0; int lsum = sum(root->left); int rsum = sum(root->right); root->data = lsum + rsum + root->data; return root->data; }
No comments:
Post a Comment