- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Postfix Notation?
In postfix notation, the operator appears after the operands, i.e., the operator between operands is taken out & is attached after operands.
Example1 − Translate a ∗ d − (b + c) into Postfix form.
ad ∗ bc + −
Example2 − Convert a + (b ∗⊝ c) is in Postfix form.
Here ⊝ represents the unary minus operator.
a b c ⊝ ∗ +
Example3 − Convert Postfix Expression into Infix Expression using Stack Implementation
a d ∗ bc + −
|ad ∗ bc + −|
|*||(a * d)|
|B||(a * d)b|
|C||(a * d)b c|
|+||(a ∗ d)(b + c)|
|-||(a ∗ d)-(b + c)|
Example4 − Calculate the value for the postfix expression.
57 + 2 ∗ 3/
This expression can be evaluated by using a stack. Each symbol can be inserted sequence wise & the operator can be applied on operands lying at the top of the stack and next to it.
|7||5 7||5 + 7|
|*||24||12 * 2|
∴ Answer is 8.
Postfix Notations used in Control Statements
- Jump − Jump to label 𝑙 can be written in postfix notations as −
- jlt (Jump if less than) − e1 e2 𝑙 jlt makes the jump to label if e1 has a smaller value than e2.
- jeqz (jump if equal to zero) − e 𝑙 jeqz causes jump to 𝑙 if e has the value zero.
Example5 − Convert the following statement into postfix Notation.
if e then x else y
If − else statement can be written as
If e then
The postfix Notation will be
Example6 − Convert expression into Postfix Notation.
if a then if c + d then a + c else a * c else a + b.
It can be written as
if a then
if c + d then
a + c
a * c
𝑙2: a + b
- Program to evaluate Postfix Notation in C++
- What is python .. ("dot dot") notation syntax?
- What is Instantaneous Description and Turnstile Notation?
- What are postfix operators in C++?
- What are postfix operators in C#?
- What is the difference between prefix and postfix operators in C++?
- What is Raw String Notation in Python regular expression?
- What is IPV4 address notation and hierarchy of addressing?
- Evaluate Postfix Expression
- Postfix to Infix in C++
- Convert Infix to Postfix Expression
- Prefix to Postfix Conversion in C++