Skip to content
doubtly

1 answer

Best answer

Answer: Taking "bc" as \(b \times c\), the expression is \(\big(a + ((b*c)*d)\big) + (e*f)\), so the root is the last + and the tree is:

              +
            /   \
          +       *
         / \     / \
        a   *   e   f
           / \
          *   d
         / \
        b   c

How to build it

  1. In an expression tree, operands are leaves and operators are internal nodes. The operator applied last becomes the root.
  2. Apply precedence: * is done before +, and operators of equal precedence go left to right. So \((b*c)*d\) and \((e*f)\) are worked out first.
  3. The two + signs are then applied left to right: first \(a + ((b*c)*d)\), then that result \(+ (e*f)\). So the second + is the root.
  4. Left subtree of the root: + with children \(a\) and \((b*c)*d\). Right subtree: * with children \(e\) and \(f\).

Check: the postorder traversal of this tree gives the postfix form a b c * d * + e f * +, which evaluates the expression correctly.

Doubtly AI · 23 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.