Posts

Showing posts with the label Arithmetic Expression Using Stack

Conversion of Arithmetic Expression Using Stack

Image
Stack has various application as we have discussed in the previous post. In this post, we will see how stack is useful to convert the user input expression into a meaningful result. There are basically three types of expression: Infix expression Postfix expression Prefix expression We generally write any equation in the form of infix expression, but computer system convert this expression into Post-fix or Prefix expression for evaluating the results. Example: Infix expressions:      A+B , X*(Y+Z)                 Postfix expression:    AB+ , XYZ+*                 Prefix expression:     +AB, *X+YZ The transformation  of any Infix expression into Postfix expression is performed based on the precedence of the operators.  The higher precedence operator evaluation is performed first, later the others operators.   If two operato...