© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

Home Lab Exercise Data Structures Lab Exercise ProgramsImplementation Postfix Expression Evaluation▼

Implementation Postfix Expression Evaluation:

Postfix Evaluation:

Infix Expression :

Any expression in the standard form like "2*3-4/5" is an Infix( Inorder) expression.

Postfix Expression :

The Postfix ( Postorder) form of the above expression is "23*45/-".

Postfix Evaluation :

In normal algebra we use the infix notation like a+b*c. The corresponding postfix notation is abc*+.

Algorithm Steps:

  • Scan the Postfix string from left to right.
  • Initialize an empty stack.
  • If the scanned character is an operand, add it to the stack. If the scanned character is an operator, there will be atleast two operands in the stack.
  • If the scanned character is an Operator, then we store the top most element of the stack(top Stack) in a variable temp. Pop the stack. Now evaluate top Stack(Operator)temp. Let the result of this operation be ret Val. Pop the stack and Push ret Val into the stack.

  • Repeat this step till all the characters are scanned.

  • After all characters are scanned, we will have only one element in the stack. Return top Stack.
C Program To Implement Postfix Expression Evaluation

CPP Program To Implement Postfix Expression Evaluation
 
SLogix Student Projects
bottom