InterviewSolution
Saved Bookmarks
| 1. |
The equivalent infix expression and value for the postfix form 1 2 + 3 * 4 5 * – will be ___________(a) 1 + 2 * 3 – 4 * 5 and -13(b) (2 + 1) * (3 – 4) * 5 and 13(c) 1 + 2 * (3 – 4) * 5 and -11(d) (1 + 2) * 3 – (4 * 5) and -11My doubt stems from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms II have been asked this question in an interview for job. |
|
Answer» CORRECT answer is (d) (1 + 2) * 3 – (4 * 5) and -11 Given postfix expression : 1 2 + 3 * 4 5 * – ⇒ (1 + 2) 3 * 4 5 * – ⇒ ((1 + 2) * 3) 4 5 * – ⇒ ((1 + 2) * 3) (4 * 5) – ⇒ ((1 + 2) * 3) – (4 * 5) So, the equivalent infix expression is (1 + 2) * 3 – (4 * 5) and it’s VALUE is -11. |
|