401 views

1 Answer

Best answer
2 votes
2 votes

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

Related questions

0 votes
0 votes
1 answer
1
I_am_winner asked Jul 20, 2018
199 views
Its answer comes to be in table [5] what should be answer as it starts from 0 then I think answer should be 6 but in test it was given as 5 . please answer
0 votes
0 votes
1 answer
3
1 votes
1 votes
1 answer
4
srestha asked May 2, 2019
502 views
A $d-$ary heap is a binary heap, but instead of $2$ children, nodes have $d$ children. A $d-ary$ heap can be represented by $1-D$ array as follows. The root is kept in $A...