PlanetMath (more info)
 Math for the people, by the people. Sponsor PlanetMath
Encyclopedia | Requests | Forums | Docs | Wiki | Random | RSS  
Login
create new user
name:
pass:
forget your password?
Main Menu
Owner confidence rating: High Entry average rating: No information on entry rating
[parent] more examples of reverse Polish notation (Example)

The following examples, presented first in standard infix notation, converted to reverse Polish notation by using the shunting yard algorithm, all use the same four operands but combined with different operators and parentheses. Operators are assumed to be binary.

$(1 + 2) \times (3 + 4)$ in standard infix notation becomes $1 \quad 2 + 3 \quad 4 + \quad \times$ in reverse Polish notation. Both expressions should evaluate to 21, each in the appropriate calculator.

$1 + 2 \times 3 + 4$ standard becomes $1 \quad 2 \quad 3 \times 4 +$ RPN. Both evaluate to 11.

$1 + 2 \times (3 + 4)$ turns to $1 \quad 2 \quad 3 \quad 4 + \quad \times \quad +$ Evaluate to 15.

$(1 + 2) \times 3 + 4$ is $1 \quad 2 + 3 \times 4 +$ Evaluate to 13.




"more examples of reverse Polish notation" is owned by Mravinci.
(view preamble | get metadata)

View style:


This object's parent.
Log in to rate this entry.
(view current ratings)

Cross-references: calculator, expressions, binary, operators, shunting yard algorithm, reverse Polish notation, infix notation

This is version 2 of more examples of reverse Polish notation, born on 2006-08-16, modified 2006-09-06.
Object id is 8257, canonical name is MoreExamplesOfReversePolishNotation.
Accessed 2254 times total.

Classification:
AMS MSC68N17 (Computer science :: Software :: Logic programming)
 03B70 (Mathematical logic and foundations :: General logic :: Logic in computer science)

Pending Errata and Addenda
None.
[ View all 1 ]
Discussion
Style: Expand: Order:
forum policy

No messages.

Interact
post | correct | update request | add example | add (any)