17. 17
Applications Of Stack
Convert infix expression to postfix and prefix
expressions
Evaluate the postfix expression
Reverse a string
Check well-formed (nested) parenthesis
Reverse a string
Process subprogram function calls
Parse (analyze the structure) of computer programs
Simulate recursion
In computations like decimal to binary conversion
In Backtracking algorithms (often used in
optimizations
and in games)
18. 18
Expression Evaluation And
Conversion
The most frequent application of stacks is in evaluation of
arithmetic expressions.
An arithmetic expression is made up of operands, operators,
and delimiters.
When higher level programming language came into existence
one of the major difficulty faced by computer scientists was to
generate machine language instruction, which would properly
evaluate any arithmetic expression.
19. 19
The following operators are written is in
descending order of their precedence:
Exponentiation ^, Unary +, Unary –, and not ~
Multiplication * and division /
Addition + and subtraction –
<, £ , =, ¹, ³, >
AND
OR
20. 20
The Operators and priorities
Oxferd UnivercityData Structures in C++ by Dr. Varsha Patil
21. 21
Polish Notation and Expression Conversion:
Polish Mathematician Han Lukasiewicz suggested a notation
called pPolish notation, which gives two alternatives to
represent an arithmetic expression, the notation are postfix
and prefix notations
The fundamental property of Polish notation is that the order
in which the operations are to be performed is determined by the
positions of the operators and operands in the expression.
Hence the advantage is parenthesis is not required while writing
expressions in pPolish notation