Infix to postfix 2011

Convert the following infix expression to its postfix form

a + b * c  – d / e

input      action         stack status   output

c             push           c                   

a             print           c                    a

+            push           c+                 a

b            print           c+                 ab

*            push           c+*               ab

c             print           c+*               abc

–             push           c+*-              abc

              pop             c+                 abc*-

d            print           c+                 abc*-d

/             push           c+/                abc*-d

              pop             c/                   abc*d+

(             print           c/                   abc*d+e

)             pop                                  abc*d+e/

Postfix   abc*d+c/

This entry was posted in infix. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *