How do you evaluate the expression in postfix form? For example, what is the answer of 5 10 2 * + 3 -  

So, in our example, 5 10 2 * + 3 -

  1. we push 5, 10, and 2 into stack, like .  
  2. Then you see an operator and pop 2 numbers out from the stack.   
  3. You will do 10*2 = 20.  
  4. Push 20 into stack.  
  5. After that you see +, you pop two numbers out.  This point of time the stack is empty.  
  6. You do 5 + 20=25.  
  7. You push the answer 25 into the stack.  You read 3 and push into stack.   
  8. Finally, you see a subtraction sign and pop two numbers out. 
  9. Do 25 - 3 =22.  
  10. Since there is no more element in the expression, you got the solution 22 for this expression..