Page 3 - DATA STRUCTURE-STACKS & QUEUES
P. 3

B)  Algorithm – Evaluation of Postfix Expression
                   1.  Let P be the expression in POSTFIX notation
                   2.  Scan P from left to write and repeat steps 3 to 4 for each element of P
                   3.  If (element = operand) Push it into Stack
                   4.  If (element = operator)
                         i.   POP first element from TOP and let it be A
                         ii.   POP second element from TOP and let it be B
                        iii.   Perform OPERATION B operator A
                        iv.   PUSH result in STACK
                   5.  POP the value from stack TOP which is result of the expression

               Solve the following expression using Stack
               5 4 6 + * 4 9 3 / + *
   1   2   3   4   5