MENU
Question -

Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation:
5,3,2, *, 4,2, /, -,*



Answer -

SYMBOL

STACK

OUTPUT

5

5

3

5,3

2

5,3,2

*

PUSH 3,2

Perform 3*2=6

POP 6

5

5

5,6

4

5,6,4

2

5,6,4,2

/

PUSH 4,2

Perform 4/2=2

POP2

5,6

5,6

5,6,2

PUSH 6,2

Perform 6-2=4

POP 4

5

5

5,4

*

PUSH 5,4

perform 5*4=20.

POP 20

20

Result=20

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×