in DS edited by
12,938 views
9 votes
9 votes

Choose the equivalent prefix form of the following expression

(a+(b-c))*((d-e)/(f+g-h))

  1. *+a-bc/-de-+fgh
  2. *+a-bc-/de-+fgh
  3. *+a-bc/-ed-+fgh
  4. *+ab-c/-de-+fgh
in DS edited by
by
12.9k views

3 Answers

13 votes
13 votes
Best answer
$( a + ( b - c ) ) * ( ( d - e ) / ( f + g - h ) )$

$( a + ( b - c ) ) * ( ( - de) / ( ( + f g) - h ) )$

$( a + ( - bc ) ) * ( ( - de ) / ( - + f g h ) )$

$( + a - b c)  *  ( / - d e - + f g h)$

$* + a - b c / - d e - + f g h$

Option $A$ will be correct.
edited by
5 votes
5 votes

(A) option answer .

3 votes
3 votes

To find the equivalent prefix form (or Polish Notation):

1) The given expression is in infix form i.e. fully parenthesized unambigous expression

2) Firstly,we have to make a rooted binary tree for the given expression

3) Then we have to apply Preorder Tree Traversals

4) The obtained expression would be an equivalent prefix or polish notation

On solving we can check that A is the correct answer...