Thursday, 18 August 2016

Conversion of Infix expression to Postfix expression Example 2

Conversion of Infix expression to Postfix expression

Example 2:

Given Infix Expression:         7 + 5 * 3 ^ 2 / ( 9 – 2 ^ 2 ) + 6 * 4



Symbol
Operator Stack
Postfix String
[0]
[1]
[2]
[3]
[4]

1
7






7
2
+
+





7
3
5
+





75
4
*
+
*




75
5
3
+
*




753
6
^
+
*
^



753
7
2
+
*
^



7532
8
/
+
/




7532^*
9
(
+
/
(



7532^*
10
9
+
/
(



7532^*9
11
-
+
/
(
-


7532^*9
12
2
+
/
(
-


7532^*92
13
^
+
/
(
-
^

7532^*92
14
2
+
/
(
-
^

7532^*922
15
)
+
/




7532^*922^-
16
+
+





7532^*922^-/+
17
6
+





7532^*922^-/+6
18
*
+
*




7532^*922^-/+6
19
4
+
*




7532^*922^-/+64
20

Stack empty
7532^*922^-/+64*+


So the postfix expression is  7532^*922^-/+64*+