edited by
2,872 views
4 votes
4 votes

Convert the pre-fix expression to in-fix $- ^{\ast} +ABC^{\ast} – DE+FG$

  1. $(A-B)^{\ast}C+(D^{\ast}E)-(F+G)$
  2. $(A+B)^{\ast}C-(D-E)^{\ast}(F+G)$
  3. $(A+B-C)^{\ast}(D-E)^{\ast}(F+G)$
  4. $(A+B)^{\ast}C-(D^{\ast}E)-(F+G)$
edited by

3 Answers

5 votes
5 votes
$\underline{\textbf{Answer:}\Rightarrow}\;\text{Option B}$

$\mathbf{((A+B)*C)-((D-E)*(F+G)))}$
edited by
0 votes
0 votes

Infix should be: (((A+B)*C)-((D-E)*(F+G)))

I have tried it here: 

https://ide.geeksforgeeks.org/0C6l9aF7gd 

 

Code source: https://www.geeksforgeeks.org/prefix-infix-conversion/ 

edited by
0 votes
0 votes
Just scan the operands from right to left and try to keep inside parantheses and update the parentheses as per requirement .

Step1 : (F+G)

Step2:(D-E) (F+G)

Step3:((D-E)*(F+G))

Step4:(skip C for now as we don't get any operator for the consecutive operands i.e. for BC)

Final Step:((A+B)*C)-((D-E)*(F+G))

Hence , Option B is correct.
Answer:

Related questions

2 votes
2 votes
3 answers
1
6 votes
6 votes
3 answers
2
Satbir asked Jan 13, 2020
3,243 views
Of the following, which best approximates the ratio of the number of nonterminal nodes in the total number of nodes in a complete $K$-ary tree of depth $N$ ?$1/N$$N-1/N$$...
5 votes
5 votes
3 answers
3
Satbir asked Jan 13, 2020
5,704 views
The minimum height of an AVL tree with $n$ nodes is$\text{Ceil } (\log_2(n+1))$$1.44\ \log_2n$$\text{Floor } (\log_2(n+1))$$1.64\ \log_2n$