Evaluate a +/- expression tree
Problem A binary tree encodes an arithmetic expression: internal nodes are '+' or '-' operators, leaves are numeric values. Compute the value at the root.
Input / Output
- Input: root of the expression tree.
- Output: evaluated integer.
Constraints
- Tree depth may be large — discuss recursion limits; operators are binary (exactly two children).
Example
- (+ (- 5 2) 3) → 6.
asked …