Skip to content
doubtly

1 answer

Best answer

The root is *; its left subtree is a + (b − c) and its right subtree is (d − e) / ((f + g) − h).

                *
             /     \
           +         /
          / \      /    \
         a   -    -      -
            / \  / \    / \
           b   c d   e  +   h
                       / \
                      f   g

How it is built:

  • The last operator applied is * between the two square brackets, so it is the root.
  • Left bracket a + (b − c): + with left child a and right child the subtree b − c.
  • Right bracket: / with left child d − e. Its right child is f + g − h, which is evaluated left to right as (f + g) − h, so − is the parent with children f + g and h.

Every operator is an internal node with exactly two children, and every operand (a to h) is a leaf. Check: the inorder traversal gives back the expression, and the postorder gives a b c - + d e - f g + h - / *.

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.