Counting subtrees where nodes sum to a specific value

Counting subtrees where nodes sum to a specific value

We will learn about counting the subtrees in a binary tree whose nodes sum to a given value. We will be trying different methods to solve our problem We will solve it in O(N) time complexity and O(H) space complexity where N is number of nodes and H is the height of the tree.


Problem:

Counting subtrees where nodes sum to a specific value


Let's say we need to find count of subtrees whose nodes sum to 11.In the example subtree,the whole left subtree's nodes sum up to 11 and the leaf itself is 11.So the total number of subtrees whose nodes added up t...

 •  0 comments  •  flag
Share on Twitter
Published on November 08, 2020 13:32
No comments have been added yet.