background preloader

Assignment 1

Facebook Twitter

Reverse Polish notation. During the 1970s and 1980s, RPN was known to many calculator users, as it was used in some handheld calculators of the time designed for advanced users: for example, the HP-10C series and Sinclair Scientific calculators. Most of what follows is about binary operators. A unary operator for which the reverse Polish notation is the general convention is the factorial.

Explanation[edit] Despite the name, reverse Polish notation is not exactly the reverse of Polish notation, for the operands of non-commutative operations are still written in the conventional order (e.g. "/ 6 3" in Polish notation and "6 3 /" in reverse Polish both evaluate to 2, whereas "3 6 /" in reverse Polish notation would evaluate to ½).

Practical implications[edit] In comparison testing of reverse Polish notation with algebraic notation, reverse Polish has been found to lead to faster calculations, for two reasons. Postfix algorithm[edit] The algorithm for evaluating any postfix expression is fairly straightforward: Evaluation of Prefix and Postfix expressions using stack. String Reference Page. C++ - Reverse polish notation interpreter/calculator. Data Structures Using C++: Using the Stack to create a RPN (post-fix notation) Calculator.