Reverse polish notation

grahamwell 2,886 views 7 slides Mar 13, 2013
Slide 1
Slide 1 of 7
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7

About This Presentation

No description available for this slideshow.


Slide Content

Reverse Polish Notation

BEDMAS BIDMAS BODMAS PEMDAS

6 2 1 2 + / * 6 2 1 2 + / * 6,2/1,2+* 6,2,1,2,+*/

Evaluating RPN Uses a stack and two simple rules. Reading left to right ……. 1. If a value appears next in the expression, push this value on to the stack . 2. If an operator appears next, pop two items from the top of the stack and push the result of the operation on to the stack .

7,4+3- 7+4-3 1,2*3+ 1*2+3 1,2+3* (1+2) *3 5,9,2*+ 5+9*2 1,2*3,4*+ 1*2+3*4 Reverse Polish Notation Examples

Converting from infix to postfix ‘Shunting yard algorithm’ Read each character If its an operand, add it to the output If it’s an operator then If there’s a higher BODMAS priority operator at the top of the stack, pop it Push it on the stack At the end, pop everything off the operator stack Calculator - another
Tags