CSC212 Homework 4 2014

From dftwiki3
Revision as of 15:49, 1 October 2014 by Thiebaut (talk | contribs) (Created page with "--~~~~ ---- =Problem #1= <br /> Write a program that computes the result of an arithmetic expression written in ''reverse polish notation'' (RPN), also called '''postfix notat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut (talk) 15:49, 1 October 2014 (EDT)


Problem #1


Write a program that computes the result of an arithmetic expression written in reverse polish notation (RPN), also called postfix notation because the operator appears after (post) the operands. You may want to read this page introducing the concept.

A regular, error-free, arithmetic expression can be transformed into its RPN easily, as illustrated with a few examples:

regular expression RPN expression

3 + 5

3 5 +

3 * ( 5 - 2 )

3 5 2 - *

( 5 * 10 ) / ( 3 - 2 )

5 10 * 3 2 - /


Problem #1