Friday, 19 August 2016

Evaluation of Postfix Expression Examples

Evaluation of Postfix Expression Examples


Click on the examples for solutions





Evaluation of Postfix Expression Example 4

Evaluation of Postfix Expression 

Example 2:

Evaluate the following Postfix Expression:   7532^*922^-/+64*+



Symb
Operand1
Operand2
Value
Operand Stack
7



7
5



7, 5
3



7, 5, 3
2



7, 5, 3, 2
^
3
2
9
7, 5, 9
*
5
9
45
7, 45
9



7, 45, 9
2



7, 45, 9, 2
2



7, 45, 9, 2, 2
^
2
2
4
7, 45, 9, 4
-
9
4
5
7, 45, 5
/
45
5
9
7, 9
+
7
9
16
16
6



16, 6
4



16, 6, 4
*
6
4
24
16, 24
+
16
24
40
40 (Result)

Evaluation of Postfix Expression Example 3

Evaluation of Postfix Expression 

Example 3:

Evaluate the following Postfix Expression: 623+-382/+*2$3+


Symb
Operand1
Operand2
Value
Operand Stack
6



6
2



6, 2
3



6, 2, 3
+
2
3
5
6, 5
-
6
5
1
1
3



1, 3
8



1, 3, 8
2



1, 3, 8, 2
/
8
2
4
1, 3,  4
+
3
4
7
1, 7
*
1
7
7
7
2



7, 2
$
7
2
49
49
3



49, 3
+
49
3
52
52 (Result)


Evaluation of Postfix Expression Example 2

Evaluation of Postfix Expression 

Example 2:

Evaluate the following Postfix Expression:   42$3*3-84/11+/+


Symb
Operand1
Operand2
Value
Operand Stack
4



4
2



4, 2
$
4
2
16
16
3



16, 3
*
16
3
48
48
3



48, 3
-
48
3
45
45
8



45, 8
4



45, 8, 4
/
8
4
2
45, 2
1



45, 2, 1
1



45, 2, 1, 1
+
1
1
2
45, 2, 2
/
2
1
1
45, 1
+
45
1
46
46 (Result)