Sum of all nodes of a Binary Tree

Technique: FAITH technique of Recursion

Problem Link: https://practice.geeksforgeeks.org/problems/sum-of-binary-tree/1/

def sumBT(root):
 
    if(root is None):
        return 0
    
    lsum=sumBT(root.left)
    rsum=sumBT(root.right)
    return lsum+rsum+root.data

Last updated