0 votes
in Data Structures & Algorithms I by (110k points)
Consider the postfix expression 4 5 6 a b 7 8 a c, where a, b, c are operators. Operator a has higher precedence over operators b and c. Operators b and c are right associative. Then, equivalent infix expression is

(a) 4 a 5 6  b 7 8 a c

(b) 4 a 5 c 6 b 7 a 8

(c) 4 b 5 a 6 c 7 a 8

(d) 4 a 5 b 6 c 7 a 8

This intriguing question comes from Application of Stacks topic in chapter Application of Stacks of Data Structures & Algorithms I

I had been asked this question during an online exam.

1 Answer

+1 vote
by (88.2k points)
selected by
 
Best answer

Correct choice: (c) 4 b 5 a 6 c 7 a 8

Given postfix expression: 4 5 6 a b 7 8 a c

infix ⇒ 4 (5 a 6)  b (7 a 8)  c

         ⇒ (4 b (5 a 6)) (7 a 8)  c

⇒ (4 b (5 a 6)) c (7 a 8)

So, the required infix expression is 4 b 5 a 6 c 7 a 8.

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

...