0 votes
in Data Structures & Algorithms I by (110k points)
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 -11

My doubt stems from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms I

I have been asked this question in an interview for job.

1 Answer

0 votes
by (110k points)
selected by
 
Best 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.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...