in DS edited by
966 views
0 votes
0 votes

The equivalent postfix expression for $d{\large /}(e+f)+b*c$ :

  1. $defbc/++*$
  2. $def+/bc+*$
  3. $def+/bc*+$
  4. None of these
in DS edited by
966 views

1 comment

Correct answer should be C.
0
0

2 Answers

0 votes
0 votes

Fully parenthesized expression: ((d/(e+f))+(b∗c))

Equivalent Postfix expression: def+/bc∗+

Replace ")" with the enclosed operator and remove the corresponding "(". Start with inner most expression.

Hence, option C is correct.

0 votes
0 votes
The steps are as follows:

$d/(e+f)+b*c$

$\implies ((d/(e+f))+(b*c))$

$\implies((d/ \ ef+))+(b*c))$

$\implies ((def+/)+(b*c))$

$\implies (def+/)+\ bc*$

$\implies def+/ \ bc* \ +$

Option $(C)$ is correct.

Note :1) Parenthesis $()$ is having the highest priority and associativity is left to right.

          2)  Division $(/)$, multiplication $(*)$ having less priority than parenthesis but high than addition $(+)$ operator. all of them having associativity is left to right.

          3) In infix expression operator is placed between operand while in postfix expression operator followed their operand.