Showing posts with label infix. Show all posts
Showing posts with label infix. Show all posts

Friday 19 August 2016

Conversion of Infix expression to Postfix expression Example 4

Conversion of Infix expression to Postfix expression 

Example 4:


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


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

1
8






8
2
*
*





8
3
(
*
(




8
4
5
*
(




85
5
^
*
(
^



85
6
4
*
(
^



854
7
+
*
(
+



854^
8
2
*
(
+



854^2
9
)
*





854^2+
10
-
-





854^2+*
11
6
-





854^2+6
12
^
-
^




854^2+6
13
2
-
^




854^2+62
14
/
-
/




854^2+62^
15
(
-
/
(



854^2+62^
16
9
-
/
(



854^2+62^9
17
*
-
/
(
*


854^2+62^9
18
3
-
/
(
*


854^2+62^93
19
)
-
/




854^2+62^93*
20


854^2+62^93*/-

So the corresponding Postfix expression is 854^2+62^93*/-

Thursday 18 August 2016

Conversion of Infix expression to Postfix expression Examples

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*+