- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- 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.

**Solution**

ad ∗ bc + −

**Example2** − Convert a + (b ∗⊝ c) is in Postfix form.

**Solution**

Here ⊝ represents the unary minus operator.

a b c ⊝ ∗ +

**Example3** − Convert Postfix Expression into Infix Expression using Stack Implementation

a d ∗ bc + −

**Solution**

String Symbols | Stack |
---|---|

ad ∗ bc + − | |

A | A |

D | ad |

* | (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/

**Solution**

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.

Symbol | Stack | Description |
---|---|---|

5 | 5 | |

7 | 5
7 | 5 + 7 |

+ | 12 | |

2 | 12
2 | |

* | 24 | 12 * 2 |

3 | 24
3 | |

/ | 8 | 24/3 |

∴ Answer is 8.

**Postfix Notations used in Control Statements**

**Jump**− Jump to label 𝑙 can be written in postfix notations as −

𝑙jump

**jlt (Jump if less than)**− e_{1}e_{2}𝑙 jlt makes the jump to label if e_{1}has a smaller value than e_{2}.**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

**Solution**

If − else statement can be written as

If e then

x

else

𝑙_{1}: y

𝑙_{2}: exit

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.

Solution

It can be written as

if a then

if c + d then

a + c

else

a * c

𝑙_{1}:

else

𝑙_{2}: a + b

𝑙_{3}: exit

- Related Articles
- 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
- Dot notation vs Bracket notation in JavaScript
- Postfix to Infix in C++
- Convert Infix to Postfix Expression
- What does a +function() { } notation do in JavaScript?
- What is the difference between `new Object()` and object literal notation in JavaScript?
- Prefix to Postfix Conversion in C++