in DS
411 views
0 votes
0 votes

in DS
by
411 views

1 Answer

2 votes
2 votes
Best answer

All options are wrong.

Answer=^6-8*24

First we convert given Postfix to Infix: Scan the i/p from L to R

push 6,push 8,push 2,push 4

Then pop 2 and 4 and push (2*4) onto stack.

Then pop (2*4) and 8 and push (8-(2*4)) onto stack.

Then pop 6 and (8-(2*4)) to get 6^(8-(2*4)) i.e 1

Now convert this infix to prefix:

=^6-8*24

Cross Check whether this prefix evaluates to 1 using PREFIX Evaluation method : scanning input from Right to Left

In prefix evaluation stack top becomes left operand of operator not the right operand ******.

push 4,push 2

pop 2,4 push (2*4)

push 8

pop 8,(2*4),push (8-(2*4))

push 6

pop last 2 stack contents =====> 6^(8-(2*4)) i.e 1

Hence our prefix is correct.

selected by

4 Comments

Thanks for confirming that answer is wrong.

Still 5 people got perfect score of $25$ in test. (how??)
0
0
which test? ACE?
1
1
Yes

Wrong questions are in every test series. But How can one do right questions correct and even wrong questions right.
0
0
Dont try to adjust according to questions. You might develop wrong assumption. Don't attempt them,just  goto next Q
1
1

Related questions