Algorithm for Evaluation of Postfix Expression

Algorithm for Evaluation of Postfix Expression

Initialize(Stack S)
x = ReadToken(); // Read Token
while(x)
{
if ( x is Operand )
Push ( x ) Onto Stack S.

if ( x is Operator )
{
Operand2 = Pop(Stack S);
Operand2 = Pop(Stack S);
Evaluate (Operand1,Operand2,Operator x);
}

x = ReadNextToken(); // Read Token
}

Live Example : 5 3 2 + 8 * +