Download presentation

Presentation is loading. Please wait.

Published byAvery Hance Modified over 2 years ago

1
Yinchong Han Linjia Jiang

2
Introduction There are three forms of expressions which are prefix, infix and postfix notation. The project will evaluate infix and postfix expressions then convert one to the other. Outline 1. Project Specification 2. Applications 3. Design & Testing 4. Conclusion

3
Project Specification Basic Concepts Expressions Infix Notation Postfix Notation Prefix Notation ExpressionsInfixPostfixPrefix

4
Expressions X = ((A/(B-C+D)) * (E-A) * C Made of operands, operators, and delimiters. Operands can be any legal variable name or constant. The values that variables take must be consistent with the operations performed on them. These operations are described by the operators. First, there are the basic arithmetic operators: plus, minus, times, and divide (+, −, *, /). Other arithmetic operators include unary minus, and %. A second class is the relational operators:, >=, and >. These are usually defined to work for arithmetic operands.

5
Priority of operators Within any pair of parentheses the operators have the highest priority. Priority of operators

6
Infix Notation X + Y Operators are written in-between their operands. A * ( B + C ) / D means: "First add B and C together, then multiply the result by A, then divide by D to give the final answer." Infix notation needs extra information to make the order of evaluation of the operators clear

7
Postfix Notation X Y + "Reverse Polish notation“ Operators are written after their operands. The infix expression given above ” A * ( B + C ) / D” is equivalent to A B C + * D / Order. Operators act on values immediately to the left of them. (A (B C +) *) D /)

8
Prefix Notation + X Y Prefix notation (also known as "Polish notation) Operators are written before their operands. The expression given above ” A * ( B + C ) / D” is equivalent to / * A + B C D Order. Operators act on the two nearest values on the right. /(* A (+ B C) ) D) Compare to Postfix Notation

9
Converting between Infix and Postfix InfixPostfix ( (A * B) + (C / D) )( (A B *) (C D /) +) ((A * (B + C) ) / D)( (A (B C +) *) D /) (A * (B + (C / D) ) )(A (B (C D /) +) *) It is simple to describe an algorithm for producing postfix from infix: 1.Fully parenthesize the expression. 2.Move all operators so that they replace their corresponding right parentheses. 3.Delete all parentheses.

10
Converting between Infix and Postfix For example, A/B − C + D *E − A *C, 1.Fully bracket the expression. 2. Move all operators so that they replace their corresponding right brackets. 3. Delete all brackets.

11
Converting between Infix and Prefix For example, since we want A + B *C to yield ABC * +

12
Advantages of using postfix notation Whilst postfix notation might look confusing to begin with, it has several important advantages: it is unambiguous it is more concise it fits naturally with a stack-based system

13
Design & Testing Run Program: Testing

14
Conclusion 1.We have understand the theory and basic concepts first. After researching on websites and reading the textbook, we totally understand the concepts and know how to code the program. 2.We are working on our program which can convert infix form and postfix form of expressions one another. 3.After the finishing of the program, we will complete a final report at the end of this semester.

15
References List 1. Horowitz, E., Sahni, S., & Mehta, D. (1995). Fundamentals of Data Structures in C++, 147-154. 2. Deitel, P., Deitel, H. (2008). Visual C#: How to Program.

Similar presentations

Presentation is loading. Please wait....

OK

Lecture 8 Tree.

Lecture 8 Tree.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on 48 laws of power Ppt on conservation of momentum formula Download ppt on turbo generator aircraft Ppt on latest technology in communication Micro display ppt on tv Ppt on dc motor working Ppt on child labour in world Ppt on second law of thermodynamics for kids Ppt on organizational culture and values Ppt on lunar and solar eclipse