img
Question:
Published on: 23 January, 2022

Convert the following infix expression to postfix notation by showing the operator stack and output string after reading each input token :

A * B + C *( D – E ) — F * G

 

Answer:

 

Sl-No

Symbol Scan

Stack

Postfix Expression

1

A

 

A

2

*

*

A

3

B

*

AB

4

+

+

AB*

5

C

+

AB*C

6

*

+ *

AB*C

7

(

+ *

AB*C

8

D

+ * (

AB*CD

9

-

+ * ( -

AB*CD

10

E

+ * ( -

AB*CDE

11

)

+ *

AB*CDE-

12

-

-

AB*CDE-*+

12

F

-

AB*CDE-*+F

13

*

- *

AB*CDE-*+F

14

G

- *

AB*CDE-*+FG

15

 

-

AB*CDE-*+FG*

16

 

 

AB*CDE-*+FG*-

 

 

 

 

Random questions