Check if a binary tree is a sum tree

geeksforgeeks.org

A binary tree is identified as a Sum Tree if every non-leaf node's value equals the sum of all nodes in its left and right subtrees. This property is checked recursively. An empty tree or a leaf node is considered a Sum Tree. For other nodes, the sums of their left and right subtrees are calculated and compared to the node's value. The most efficient method achieves this in linear time by using a post-order traversal, calculating subtree sums and verifying the Sum Tree property in a single pass.


With a significance score of 1.4, this news ranks in the top 40% of today's 33011 analyzed articles.

Get summaries of news with significance over 5.5 (usually ~10 stories per week). Read by 10,000+ subscribers:


Check if a binary tree is a sum tree | News Minimalist