KUMAR SHIVAM

Define Evaluation of Postfix expression. Explain algorithm and example for it ? 

Data Structures and Algorithms

Answer in Short

A postfix expression can be evaluated using the Stack data structure....A common technique is to convert a infix notation into postfix notation, then evaluating it.

Explanation

967    0

==> Evaluation of Postfix expression---

  • In high level languages, infix notation cannot be used to evaluate expressions
  • Instead compilers typically use a parenthesis free notation to evaluate the expression
  • A common technique is to convert a infix notation into postfix notation, then evaluating it.
  • Before knowing the function that translates infix expression to postfix expression, we need to know how to evaluate the postfix expression.                                                                                                         45+ will be evaluate as 4+5=9
  • To evaluate an expression we make single left to right scan (read) of it. We place the operands on a stack until we find an operator. We then remove, from the stack, correct number of operands for the operator, perform operation, and place the result back on the stack. We continue until we reach the end of the expression. We remove the result top of the stack.




Share:   

More Questions from Data Structures and Algorithms Module 2