This project may need some explanation by an instructor
A numerical expression is a mathematical statement that involves numbers and operation symbols.
Infix expressions are characterized by the placement of operators between operands. (e.g. 6 + 3)
Postfix expressions are characterized by placement of operators after the operands. (e.g. 6 3 +)
Reverse Polish notation (RPN) is postfix notation.
The description "Polish" refers to the nationality of logician Jan Ćukasiewicz, who invented Polish notation in 1924.
For example:
| Infix Expression | Results | Reverse Polish Notation Expression | Notes |
|---|---|---|---|
| 5 + 2 + 8 | 15 | 5 2 + 8 + | same operator precedence |
| 5 + 2 * 8 | 21 | 5 2 8 * + | different operator precedences |
| (5 + 2) * 8 | 56 | 5 2 + 8 * | sub-expression |
| 2 ** 4 + 5 | 21 | 2 4 ** 5 + | mult-character (**) operator |
| (10 / 2) * 3 | 15 | 10 2 / 3 * | sub-expression |
| ((2 * 3) - (4 - 8 * 2)) | 18 | 2 3 * 4 8 2 * - - | sub-expression | ((2 * 3) - (4 * 8 - 2)) | -24 | 2 3 * 4 8 * 2 - - | sub-expression |
| 2**3 - 4 * 2 | 0 | 2 3 ** 4 2 * - | mult-character (**) operator |
For hints, code examples, etc. click
HERE
.
What is the difference between the Python "collections.deque" and "Queue" modules?
Using the Python "collections.deque" module, create a stack class (LIFO queue). Implement the following methods:
Create an interactive program to demonstrate the stack methods.
Are there any other methods that are needed?
Using the Python "collections.deque" module, create a queue class (FIFO queue). Implement the following methods:
Create an interactive program to demonstrate the queue methods.
Are there any other methods that are needed?
Create an interactive program to tokenize an infix numerical expression.
.
Define "syntax" and "semantics" as they relate to computer programming languages.
Create an interactive program to convert an infix numeric expressions
to a Reverse Polish Notation (RPN) numeric expressions.
Code the algorithm found
HERE
.
Expand the project
Infix notation (Wikipedia)
Reverse Polish notation (Wikipedia)
Shunting yard algorithm (Wikipedia)
Infix, Postfix and Prefix Expressions/Notations
Converting infix to RPN (shunting-yard algorithm)
Rules to Convert Infix to Postfix (Reverse Polish) Expression using a Stack (YouTube)
How to convert Infix expressions to Reverse Polish Notation expressions (Youtube)