CSC212 Homework 4 2014
--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 - / |