- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

The way to write arithmetic expression is known as a notation. An arithmetic expression can be written in three different but equivalent notations, i.e., without changing the essence or output of an expression. These notations are –

Infix

Prefix

Postfix

Infix notations are normal notations, that are used by us while write different mathematical expressions. The Prefix and Postfix notations are quite different.

In this notation, operator is **prefixed** to operands, i.e. operator is written ahead of operands. For example, **+ab**. This is equivalent to its infix notation **a + b**. Prefix notation is also known as **Polish Notation**.

This notation style is known as **Reversed Polish Notation**. In this notation style, the operator is **postfixed** to the operands i.e., the operator is written after the operands. For example, **ab+**. This is equivalent to its infix notation **a + b**.

Expression No | Infix Notation | Prefix Notation | Postfix Notation |

1 | a + b | + a b | a b + |

2 | (a + b) * c | * + a b c | a b + c * |

3 | a * (b + c) | * a + b c | a b c + * |

4 | a / b + c / d | + / a b / c d | a b / c d / + |

5 | (a + b) * (c + d) | * + a b + c d | a b + c d + * |

6 | ((a + b) * c) - d | - * + a b c d | a b + c * d - |

As we have discussed, it is not a very efficient way to design an algorithm or program to parse infix notations. Instead, these infix notations are first converted into either postfix or prefix notations and then computed.

To parse any arithmetic expression, we need to take care of operator precedence and associativity also.

When an operand is in between two different operators, which operator will take the operand first, is decided by the precedence of an operator over others. For example –

𝑎 + 𝑏 ∗ 𝑐 → 𝑎 + (𝑏 ∗ 𝑐)

As multiplication operation has precedence over addition, b * c will be evaluated first. A table of operator precedence is provided later.

- Related Questions & Answers
- Difference between prefix and postfix operators in C#?
- Precedence of postfix ++ and prefix ++ in C/C++
- Prefix to Postfix Conversion in C++
- What is the difference between prefix and postfix operators in C++?
- Differentiate between the prefix and postfix forms of the ++ operator in java?
- Evaluation of Prefix Expressions in C++
- Difference between data type and data structure
- Rectangle Data in Data Structure
- Huffman Codes and Entropy in Data Structure
- Adaptive Merging and Sorting in Data Structure
- Compressed Quadtrees and Octrees in Data Structure
- Time and Space Complexity in Data Structure
- Eulerian and Hamiltonian Graphs in Data Structure
- Halfedge data structure
- Deaps in Data Structure

Advertisements