Evaluating postfix and infix expression

So given an expression in postfix form evaluate the expression

The idea is to use stacks to store operands . Whenever we see an operand we push it on stack . When we see an operator we pop out the two values from the operand do the operation and push the result back on the operand

After we run through the array the final result should be at the top of the stack

For Infix we should use two stacks one for operator and the other for operand the key is to do the operation instructed by operator on operands as we run through the array.

We should do the operation indicated by operand as long as we do not find any operator whose precedence is less than the given operator

Like what you read? Give Nitish Chandra a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.