Question:medium

Consider the binary tree given below. What will be the corresponding infix expression to this? 

Show Hint

In an expression tree, the operators are located at the internal nodes, and the operands are at the leaf nodes. Use infix traversal to determine the corresponding expression.
Updated On: Jan 17, 2026
  • ((a + b + c * d) % (f \^ g) / (g - h))
  • (a - b) - (c * d) % ((f \^ i) + (g / h))
  • ((a + b) - (c * d)) % ((f \^ g) / (h - i))
  • ((a + b) - (c * d)) / ((f \^ g) / (h - i))
Show Solution

The Correct Option is C

Solution and Explanation

Step 1: Analyze the Binary Tree Structure.
Internal nodes represent operators, while leaf nodes represent operands. The sequence of operations is determined by an infix traversal: left operand, operator, right operand.

Step 2: Execute Infix Traversal. 
The provided binary tree translates to the following infix expression: 

- Root node (`-`) applies to its left and right subtrees. 

- The left subtree (rooted at `+`) yields the expression `(a + b)`. 

- The right subtree (rooted at `*`) yields the expression `(c * d)`. 

- The rightmost subtree (rooted at `/`) represents the expression `(g - h)`. 

- The root operator `%` combines the left sub-expression `(a + b) - (c * d)` and the right sub-expression `(f ^ g) / (h - i)`. 

The complete infix expression is: \[ ((a + b) - (c * d)) % ((f ^ g) / (h - i)) \]

Step 3: Final Determination. 
The accurate infix expression corresponds to option (3).

Was this answer helpful?
0