Question:

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: Sep 25, 2025
  • ((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))
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Examine the Binary Tree. 
In the given tree, the operators are located at the internal nodes, and the operands are located at the leaf nodes. The order of operations is determined by traversing the tree in an infix manner (i.e., left operand, operator, right operand).

Step 2: Perform the Infix Traversal. 
The binary tree in the image represents the following infix expression: 

- Start with the root: The operator is `-`. This operator applies to the left and right subtrees. 

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

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

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

- Finally, the operator at the root of the tree `%` applies to the left expression `(a + b) - (c * d)` and the right expression `(f \^ g) / (h - i)`. 

Thus, the final expression is: \[ ((a + b) - (c * d)) % ((f ^ g) / (h - i)) \]

Step 3: Conclusion. 
The correct infix expression is option (3).

Was this answer helpful?
0
0

Questions Asked in CUET PG exam

View More Questions