Introduction to Microprocesso programming and interfacing.pptx
Polish
1. Dr. D. Y. Patil Pratishthan’s
D.Y. Patil College Of Engineering & Technology,
Kasaba Bawada, Kolhapur
A
Presentation On
“Polish Notation”
Presented By:
1.Daulmalik S. Mujawar.
2.Falaknaz N. Punekar.
3.Rohit Ugave.
4.Prajakta Suryavanshi.
2. Index
1. Abstract
2. Introduction
3. Problem Statement
4. Approaches to tackle
5. Algorithm and Flow chart
6. Important construct of PL used
7. Result : All Possible input and output
8. Conclusion
9. Application
10.References
3. Abstract
• To evaluate and simplifies the arithmetic expression given by
an user. The priorities are fixed in the project (^ then * / then +
-). The input string is given by user with minimum 2 operands
with 1 operator.
• Operator Precedence :-
Exponential Operator ^ Highest Precedence
Multiplication/ Division */ Next Precedence
Addition / Subtraction +- Least Precedence
4. Introduction
• Polish notation, also known as Polish prefix notation or simply prefix notation, is a
form of notation for logic, arithmetic, and algebra.
• Its distinguishing feature is that it places operators to the left of their operands.
• If the arty of the operators is fixed, the result is a syntax lacking parentheses or
other brackets that can still be parsed without ambiguity.
• The Polish logician Jan Łukasiewicz invented this notation in 1924 in order to
simplify sentential logic.
5. Introduction(cont..)
• Infix :- The infix notation is what we come across in our general mathematics,
where the operator is written in-between the operands.
– For E.g. :- A + B
• Prefix :- The notation in which operator is place before the operands. It is also
called as Polish notation.
– E.g. :- + A B
• Postfix :- The notation in which operator is place after the operands. It is also called
as Reverse Polish notation or simply Suffix Notation.
– E.g. :- A B +
6. Problem Statement
• Computer doesn’t understand the regular mathematical expression. So,
complier needs to converts the regular expression into polish (prefix) notation
expression for performing evaluation operation.
• Read an expression in Polish notation, To simplify the Polish notation
expression as much as possible.
Case 1: + 3 4
Case 2: - x x
Case 3: * - 6 + x -6 - - 9 6 * 0 c
7
- x x
* - 6 + x -6 - 3 * 0 c
7. APPROACHES TO TACKLE :
2.1Using Array
We use array, in which array acts as stack and push and pop operations are performed on array
stack.
Eg:-
Stc[20];
For(i=0;i<20;i++)
{
Scanf(“%d”,&a[i]);
}
2.2Using structure
In instead we can use structure to create stack and with top of stack.Object of a structure is
considered as stack, and members of structure defines top of stack, terminals and non-terminals.
Struct stack1{
Int tos=-1;
Char tr,ntr;
} s[100];
8. ALGORITHM
3.1 Logic:
1. Start.
2. Enter the mathematical expression in polish notation.
3. Check entered expression is Prefix. If NO, go to step 6
4. Evaluate the expression.
5. Display the result
6. End.
10. IMPORTANCE CONSTRUCTOR OF USED :
Work related to checking entered expression is prefix.
function’s used:
•isopnd (char)
This function is use to check the current element field is operand or not. If it’s a operand then it
will push on to the stack and pointer is move to ext position.
•isoprtr (char)
This function is use to check the current element field is operator or not. If it’s a operand then it
will push on to the stack and top is move to next position.
•evaluate (char, int, int)
This function is use to evaluate the given expression if two consecutive operator are pushed to the
stack and after that push two consecutive operands on to stack then it evaluate this expression.
•strlen()
This is a inbuilt function which is used to calculate the length of given expression.
13. Conclusion
• For evaluating given arithmetic expression Calculator /
Computer needs simplified expressions. With the help of
polish notation, the complex notation gets simplifies.
• This Program will be used to simplify the complex
mathematical polish notation expressions. This makes
compiler to read the simplified expression effectively.
15. References / Bibliography
• Books
– Data Structures with C (Schaum's Outline Series) -by Seymour Lipschutz
– Let Us C (Computer Science) -by Yashavant P. Kanetkar
• Websites
– The ACM International Collegiate Programming Contest (ICPC)
https://icpc.baylor.edu/
– Stack Overflow
http://stackoverflow.com/
– Polish notation
https://en.wikipedia.org/wiki/Polish_notation
– Tutorials Point
http://www.tutorialspoint.com/data_structures_algorithms/expressionparsing.htm