The prefix equivalent of the following infix expression is:
a/b – c + d * e – a * c
- AOption (a)
-
-
- / a b c * d e * a c
-
-
- BOption (b)
-
-
- / a b c * d e * a c
-
-
- COption (c)
-
-
- / a b c * d e * a c
-
-
- DOption (d)
-
- / a b c - * d e * a c
-
View answer & explanationHide answer & explanation
Correct answer
-
-
- / a b c * d e * a c
-
Why this answer is correct
Algorithm for conversion from prefix to infix:
STEP 1:
Start scanning the expression from RHS. Push the operators on the top of the stack by ensuring that only high priority operator can be pushed over a low priority operator.
STEP 2:
If a low priority operator is encountered in expression and if top of stack is high priority operator, then pop it and after that push low priority operator on the top of stack.
STEP 3:
Print each operand.
Given expression is : a/b – c + d * e – a * c
⇒ /ab-c+de-ac
⇒ -/abc+de-ac
⇒ +-/abcde-ac
⇒ +-/abcde-ac
⇒ +-/abc*de-*ac
⇒ -+-/abcdeac