Tuesday, 12 May 2015

Q 38,paper 3,J12. The following postfix expression is evaluated using a stack 823^/23* + 51* – The top two elements of the stack after first * is evaluated


Options (A) 6, 1 (B) 5, 7 (C) 3, 2 (D) 1, 5
Answer (A) 6,1
Explanation.
(823) operation 2^3 is done and pushed in to the stack. Stack is (8,8)
Operation is / ,calculation 8/8 =1 and pushed in to the stack and stack is(1).push 2,3. stack is(1,2,3)
Operation is *. Multiplication is done 2*3 and pushed inside the stack. Stack contents are (1,6).
So the top two elements of stack are 6,1 as by popping the contents of the stack.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.