Binary tree is sum tree or not

Write a function that returns true if the given Binary Tree is SumTree else false. A SumTree is a Binary Tree where the value of a node is equal to sum of the nodes present in its left subtree and right subtree. An empty tree is SumTree and sum of an empty tree can be considered as 0. A leaf node is also considered as SumTree.

Following is an example of SumTree.

26
/ \
10 3
/ \ \
4 6 3

Comments

Popular posts from this blog

Circular game survival