evaluate the following arithmetic expression A which is in the postfix notation show the contents of stack during the execution of algorithm using the following A= 30,5,5,^,12,6,/,+,-
Answers
Answered by
0
Answer:
ITEM
SCANNED
OPERATION STACK
2 PUSH 2 2
13 PUSH 13 2,13
+ POP 13 and 2
Evaluate 2 + 13 = 15
PUSH 15 15
5 PUSH 5 15,5
– POP 5 & 15
EVALUATE 15-5 = 10
PUSH 10 10
6 PUSH 6 10, 6
3 PUSH 3 10, 6, 3
/ POP 3 & 6
EVALUATE 6/3= 2
PUSH 2 10,2
5 PUSH 5 10, 2, 5
* POP 5 & 2
EVALUATE 2*5 = 10
PUSH 10 10, 10
< POP 10 & 10
EVALUATE
10<10 = FALSE
PUSH FALSE FALSE
RESULT = FALSE
Similar questions