Stacks and queues


#1

The following post-fix expression is evaluated using a stack
823^/24*+51*-
The top two elements of the stack after first * is evaluated are


#2

The top 2 elements of the stack after evaluation of first* here is 1, 8.
Reason:
8 S: 8
2 S: 8, 2
3 S: 8,2,3
^ S: 8,8 (2^3=8)
/ S: 1 (8/8=1)
2 S: 1,2
4 S: 1,2,4

  • S: 1, 8 (2×4=8)