## What is Polish Notation?

**Polish notation** (PN), also known as normal **Polish notation** (NPN), Łukasiewicz **notation**, Warsaw **notation**, **Polish prefix notation** or simply **prefix notation**, is a mathematical **notation** in which operators precede their operands, in contrast to the more common infix **notation**, in which operators are placed between operands.

Polish Notation refers to the notation in which the operator symbol is placed before its two operands. For example: +AB.

## Why Polish Notation is Used?

There are several benefits of Polish Notation. Most important is the computer usually evaluates an arithmetic expression written in infix notation in two steps. First it converts the expression to postfix notation, and then it evaluates the postfix expression. Which is Reverse Polish Notation. Hence we need polish notation.

## What is Reverse Polish Notation?

Reverse Polish notation, also known as Polish postfix notation or simply postfix notation, is a mathematical notation in which operators follow their operands, in contrast to Polish notation, in which operators precede their operands.

Reverse Polish Notation refers to the notation in which the operator symbol is placed after its two operands. For example: AB+.

## What is Expression?

In computer science, an **expression** is a collection of operators and operands that represents a specific value. For example: a+b*c/d

## Types of Expression

- Prefix Expression
- Postfix Expression
- Infix Expression

### Prefix Expression

Prefix expression is a set of symbol where any operator is placed before both two operands. For example: ++*AB*/*CDEF↑GH

### Postfix Expression

Postfix expression is a set of symbol where any operator is placed after both two operands. For example: AB*CDE*/F*+GH↑+

### Infix Expression

Infix expression is a set of symbol where any operator is placed between two operands. For example: A*B+(C*D/E)*F+(G↑H)

## Expression Conversion

- Infix to Prefix
- Prefix to Infix
- Infix to Postfix
- Postfix to Infix
- Prefix to Postfix
- Postfix to Prefix

Here 1 and 3 will be shown. 2 and 4 are the reverse method of 1 and 3. To calculate 5 you need to convert prefix to infix first then infix to postfix. Similarly you can do 6.

### Infix to Prefix Conversion

#### 1.

Given,

A*B+(C*D/E)*F+(G↑H)

= A*B+[/*CDE]*F+[↑GH]

= [*AB]+[*/*CDEF]+[↑GH]

= ++*AB*/*CDEF↑GH

#### 2.

Given,

1∗2/3+(4-5 ↑ 6)+7-8

= 1∗2/3+(4-[↑56])+7-8

= 1∗2/3+[-4↑56]+7-8

= [/∗123]+[-4↑56]+7-8

= -++/∗123-4↑5678

#### 3.

Given,

A+B*C/D-E+(F/G+H↑K)

= A+B*C/D-E+(F/G+[↑HK])

= A+B*C/D-E+([/FG]+[↑HK])

=A+B*C/D-E+[+/FG↑HK]

=A+[/*BCD]-E+[+/FG↑HK]

=+-+A/*BCDE+/FG↑HK

#### 4.

Given,

(1+2)↑3/4*5 +7-8 ↑9

= [+12]↑3/4*5 +7-8 ↑9

= [↑+123]/4*5 +7-[↑89]

= [*/↑+12345]+7-[↑89]

= -+*/↑+123457↑89

#### 5.

Given,

[/(*AB)C]+D↑(E-[*FG]/H

=[/*ABC]+D↑[-E*FG]/H

=[/*ABC]+[↑D-E*FG]/H

=[/*ABC]+[/↑D-E*FGH]

=+/*ABC/↑D-E*FGH

#### 6.

Given,

1+2∗3/4↑5*6-7*8

=1+2*3/[↑45])*6-7*8

=1+[/*23*↑456]-[*78]

=+1-/*23*↑456*78

#### 7.

Given,

A+(B-C)*D/E+F/G↑H

=A+[-BC]*D/E+F/G↑H

=A+[-BC]*D/E+F/[↑GH]

=A+[/*-BCDE]+[/F↑GH]

=++A/*-BCDE/F↑GH

#### 8.

Given,

(1+2)∗3-4/5∗6↑7

=[+12]∗3-4/5∗6↑7

=[+12]∗3-4/5∗[↑67]

=[*+123]-[*/45↑67]

=-*+123*/45↑67

### Infix to Postfix Conversion

#### 1.

Given,

A*B+(C*D/E)*F+(G↑H)

= A*B+[CDE*/]*F+[GH↑]

=[AB*]+[CDE*/F*]+[GH↑]

=AB*CDE*/F*+GH↑+

#### 2.

Given,

1∗2/3+(4-5 ↑ 6)+7-8

= 1∗2/3+(4-[56↑])+7-8

= 1∗2/3+[456↑+]+7-8

= [12*3/]+[456↑+]+7-8

= 12*3/456↑++7+8-

#### 3.

Given,

A+B*C/D-E+(F/G+H↑K)

= A+B*C/D-E+(F/G+[HK↑])

= A+B*C/D-E+([FG/]+[HK↑])

= A+B*C/D-E+[FG/HK↑+]

=A+[BC*D/]-E+[FG/HK↑+]

=ABC*D/+E-FG/HK↑++

#### 4.

Given,

(1+2)↑3/4*5 +7-8 ↑9

= [12+]↑3/4*5 +7-8 ↑9

= [12+3↑]/4*5 +7-[89↑]

= [12+3↑4/5*]+7-[89↑]

= 12+3↑4/5*7+89↑-

#### 5.

Given,

[/(*AB)C]+D↑(E-[*FG]/H

=[AB*C/]+D↑[EFG*-]/H

=[AB*C/]+[DEFG*-↑]/H

=AB*C/DEFG*-↑H/+

#### 6.

Given,

1+2∗3/4↑5*6-7*8

=1+2*3/[45↑])*6-7*8

=1+[23*45↑6*/]-[78*]

=123*45↑6*/+78*-

#### 7.

Given,

A+(B-C)*D/E+F/G↑H

=A+[BC-]*D/E+F/G↑H

=A+[BC-]*D/E+F/[GH↑]

=A+[BC-D*E/]+[FGH↑/]

=ABC-D*E/+FGH↑/+

#### 8.

Given,

(1+2)∗3-4/5∗6↑7

=[12+]∗3-4/5∗6↑7

=[12+]∗3-4/5∗[67↑]

=[12+3*]-[45/67↑*]

=12+3*45/67↑*-

## Drawing Tree From Expression

Given Expression: *+a-bc*-de-/fgh

Tree from Expression:

Thanks for following us.