Given a binary tree containing n nodes. The problem is to find the sum of all the parent node’s which have a child node with value x.
sumOfParentOfX(root,sum,x)
if root == NULL
return
if (root->left && root->left->data == x) ||
(root->right && root->right->data == x)
sum += root->data
Sum of all the parent nodes having child node x : https://www.geeksforgeeks.org/sum-parent-nodes-child-node-x/