Answer to Question #270927 in Algorithms for Ashu

Question #270927

Find the infix equivalents of the following postfix equivalents:

(A) A B + C * D –


1
Expert's answer
2021-11-25T00:52:55-0500

convert postfix to infix:

  • Scan the given postfix expression from left to right character by character.
  • If the character is an operand, push it into the stack.
  • But if the character is an operator, pop the top two values from stack.
  • Concatenate this operator with these two values (2nd top value+operator+1st top value) to get a new string.
  • Now push this resulting string back into the stack.
  • Repeat this process until the end of postfix expression. Now the value in the stack is the infix expression.


Postfix Expression Stack (Infix)

B + C * D – A

+ C * D – AB

C * D – (A+B)

* D – (A+B)C

   D – ((A+B)*C)

   – ((A+B)*C)D

(((A+B)*C)-D)


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS