in expression tree the integer values will be at the leaf nodes the operands will be all the other internal nodes check for leaf node evaluate left tree evaluate right tree check which operator to apply in expression tree the integer values will be at the leaf nodes the operands will be all the other internal nodes check for leaf node evaluate left tree evaluate right tree check which operator to apply
class Node:

    def __init__(self, val):
        self.val = val
        self.right = None
        self.left = None


def evaluate(root):
    if root is None:
        return 0

    
    if root.left is None and root.right is None:
        return int(root.data)

    
    left_sum = evaluate(root.left)

    
    right_sum = evaluate(root.right)

    
    if root.data == '+':
        return left_sum + right_sum

    elif root.data == '-':
        return left_sum - right_sum

    elif root.data == '*':
        return left_sum * right_sum

    else:
        return left_sum / right_sum