Exp 3
Exp 3
Experiment No. 3
Title: Implement stack as an ADT to perform expression conversion and evaluation for infix to
Postfix.
Outcome: Students can perform expression conversion and evaluation for infix to postfix and
its related applications.
Theory:
These complex arithmetic operations can be converted into polish notation using stacks which
then can be executed in two operands and an operator form.
Infix Expression
Postfix Expression
The Postfix notation is used to represent algebraic expressions. The expressions written in
postfix form are evaluated faster compared to infix notation as parenthesis are not required in
postfix.
An infix expression is difficult for the machine to know and keep track of precedence of
operators. On the other hand, a postfix expression itself determines the precedence of operators
(as the placement of operators in a postfix expression depends upon its precedence).Therefore,
for the machine it is easier to carry out a postfix expression than an infix expression.
Analysis:
1.
2.
3.
Title Program:
Practice Program:
Screenshots of Output:
Conclusion: