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.
Input : Binary tree with x = 2:
4
/ \
2 5
/ \ / \
7 2 2 3
Output : 11
4
/ \
2 5
/ \ / \
7 2 2 3
The highlighted nodes (4, 2, 5) above
are the nodes having 2 as a child node.