Postfix notation facts for kids
![]() |
Prefix notation |
Infix notation |
Postfix notation |
Postfix notation is a special way to write down math problems and formulas. It's also known as Reverse Polish Notation. This method was created by Charles Hamblin in 1920. He wanted to make writing logic equations simpler. He was inspired by Jan Łukasiewicz's prefix notation.
With postfix notation, you don't need to use grouping symbols like parentheses. This makes it easier for computers to understand. Some computer languages, like Postscript, use postfix notation. You can also find it on some Hewlett-Packard calculators.
This notation puts the math operation (like plus or minus) after the numbers it works on. Because of this, it's quite easy for computers that use a stack to do calculations.
Understanding Postfix Notation
Reverse Polish Notation uses a system called "stacks." Think of a stack like a pile of plates. You can only add or remove plates from the top. In this system, each stack holds a number. The first stack is often called the X stack, the second is the Y stack, and so on.
When you enter a new number, it goes onto the first stack. All the other numbers on the stacks move up one spot. On a Reverse Polish Notation calculator, the "Enter" button does this.
How Math Operations Work
When you use a math operation like plus, minus, multiply, or divide, it usually works with the top two numbers on the stacks. For example, if you see "12 3 /" in Reverse Polish Notation, it means "take the numbers 12 and 3, then divide 12 by 3."
On a calculator, you would type "12 Enter 3 /". The "Enter" tells the calculator to put 12 on the first stack and then move it up when 3 is entered. Then, the division symbol tells it to divide the number on the Y stack (12) by the number on the X stack (3).
Handling Parentheses in Postfix
Reverse Polish Notation can also handle math problems that normally use brackets or parentheses. Let's look at a regular math problem: "4 * (5 + 8)".
In Reverse Polish Notation, this problem would be written as "5 8 + 4 *".
- The "5 8 +" part tells the calculator to first add 5 and 8. This equals 13.
- After this addition, the result (13) is placed back on the stack.
- Then, the "4 *" part tells the calculator to multiply the result (13) by 4.
- So, 13 multiplied by 4 equals 52.
This way, the operations are done in the correct order without needing parentheses.