3.8k views

The following postfix expression with single digit operands is evaluated using a stack:

$$8 \ 2 \ 3 \ ^\hat{} / \ 2 \ 3 * + 5 \ 1 * -$$

Note that $^\hat{}$ is the exponentiation operator. The top two elements of the stack after the first $*$ is evaluated are

1. $6, 1$
2. $5, 7$
3. $3, 2$
4. $1, 5$
edited | 3.8k views
+4
The full question is not visible in GO hardcopy book which is printed.Only 823^ is visible and after some tabs /.

Anyone having GO physical copy please validate my claim.
0
Yeah it is
+1

@Arjun FYI

This question is not properly visible in the GO PDF and the hardcopy as well. The claim for inconsistency in hardcopy has been raised by @sripo and validated by

push $8$  so stack is $8$

push $2$ so stack is $8 \ 2$

push $8 \ 2 \ 3$

$^\hat{}$ pop $3$ and $2$ perform opn $2 ^\hat{} 3$ and push to stack. stack is $8 \ 8$

/ pop $8$ and $8$ perform $8/8$ and push result to stack . stack is $1$

push $2$ stack is $1 \ 2$

push $3$ stack is $1 \ 2 \ 3$

$*$ pop $3$ and $2$ perform by $2*3$ and push . stack is $1 \ 6$

Hence, answer is A.

answered by Boss (11.6k points)
edited
0

after 823 we've ^ in TOS , so we'll pop last two element & perform the operation that's fine.but my query is that why 2^3 not 3^2 & in case there is ' - ' in place of ' ^ ' then in which order it will be performed.

I mean sometimes for some operator order of the elelment will matter( e.g:' - ' & ' ^ ' as 3-2 or 2-3  and  2^3 or 3^2) Is there any general concept to remove this confusion???

0

@MRINMOY_HALDER......bottom of the element is 1st and top element 2nd......i.e    2-3=-1

better take any infix operation solve first then convert that postfix evaluate using postfix evaluation...you will get ans

 Operation Expression Stack 823 ^ /23 * 51 * - Empty Push 23 ^ /23 * 51 * - 8 Push 3 ^ /23 * 51 * - 8 2 Push ^ /23 * 51 * - 8 2 3 Pop /23 * 51 * - 8 (2^3) Pop 23 * 51 * - 8/8 Push 3 * 51 * - 1 2 Push * 51 * - 1 2 3 Pop 51 * - 1 (2*3)

So top two elements after 1st * is 6 , 1

answered by Loyal (8k points)
Ans is (A) 6 ,1
answered by Loyal (7.4k points)

1
2