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

No comments:

Post a Comment