What Is Polish Notation in Data Structure With Example?


Scott Campbell

In data structure, Polish notation, also known as prefix notation, is a way of writing arithmetic expressions. It was introduced by the Polish mathematician Jan Łukasiewicz in the 1920s. In this notation, operators are written before their operands.

Why Polish Notation?

Polish notation eliminates the need for parentheses to indicate the order of operations. It allows us to perform arithmetic operations without any ambiguity.

How Polish Notation Works

To understand how Polish notation works, let’s look at an example:

+ 5 7

In this expression, the plus operator (+) is written before its operands (5 and 7). To evaluate this expression, we simply apply the plus operator to its operands: 5 + 7 = 12.

Let’s see another example:

* + 4 6 3

In this expression, there are two operators: plus (+) and multiply (*). The plus operator has two operands: 4 and 6.

So, we evaluate the plus operation first: 4 + 6 = 10. Then, we apply the multiply operation to the result and the third operand (3): 10 * 3 = 30.

Advantages of Polish Notation

  • Simplicity: Polish notation simplifies arithmetic expressions by removing parentheses and ambiguity.
  • Efficiency: Evaluating expressions in Polish notation can be faster than evaluating infix expressions because it eliminates the need for parsing brackets.
  • No precedence rules: In Polish notation, there are no precedence rules to remember. Operators are applied strictly from left to right.

Disadvantages of Polish Notation

  • Unfamiliarity: Polish notation is not widely used, so it may be unfamiliar to many programmers.
  • Readability: Expressions in Polish notation can be harder to read and understand for beginners.

Infix to Polish Notation Conversion

To convert an infix expression to Polish notation, we can use the Shunting Yard algorithm. This algorithm was developed by Edsger Dijkstra and allows us to convert expressions efficiently.


Polish notation is a useful way of writing arithmetic expressions that eliminates the need for parentheses and ambiguity. While it may not be widely used or familiar to all programmers, understanding Polish notation can enhance your knowledge of data structures and algorithms.

Remember, practice is key when it comes to mastering concepts like the Polish notation!

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy