Advertisements
Advertisements
Question
Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion
U * V + R/(S - T)
Solution
Element | Stack | Postfix |
U | U | |
* | * | U |
V | * | UV |
+ | + | UV* |
R | + | UV*R |
/ | +/ | UV*R |
( | +/( | UV*R |
S | +/( | UV*RS |
- | +/( | UV*RS |
T | +/(- | UV*RST |
) | +/ | UV*RST- |
UV*RST-/ | ||
UV*RST/+ |
shaalaa.com
Is there an error in this question or solution?