Answer to Question #268270 in Algorithms for Tarurendra Kushwah

Question #268270

Give the infix expression of the following prefix expressions.

(A) * – + A B C D

(B) + – a * B C D


1
Expert's answer
2021-11-18T23:53:59-0500

Algorithm for Prefix to Infix:

  • Read the Prefix expression in reverse order (from right to left)
  • If the symbol is an operand, then push it onto the Stack.
  • If the symbol is an operator, then pop two operands from the Stack.
  • Repeat the above steps until end of Prefix expression.


A)

after first 4 step:

Prefix: *–+

Infix: DCBA

next:

Prefix: *–

Infix: DC(A+B)

Prefix: *

Infix: DC(A+B)-

Prefix:

Infix: DC(-*(A+B))


B)

Prefix: +–a*BC

Infix: D

Prefix: +–a*B

Infix: DC

Prefix: +–a*

Infix: DCB

Prefix: +–a

Infix: D(B*C)

Prefix: +–

Infix: D(B*C)a

Prefix: +

Infix: D(B*C)a-

Prefix:

Infix: D(B*C)(-+a)


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