The postfix expression for the infix expression $A+B*(C+D)/F+D*E$ is:
$ABCD + *F/DE* ++$
$A * B + CD/F *DE ++$
$A + *BCD/F* DE ++$
@Arjun or anyone with edit privileges, please edit the options.
@Ahwan
Not all are left-associative.
I don't know by the people here are talking about $\mathbf{By-Default}$ thing.
According to me $\underline{\text{associativity is a rule}}$ and the operators are either $\mathbf{Left\;Associative}$ or $\mathbf{Right\;Associative}$.
@Satbir
@Verma Ashish
@techbd123
@ankitgupta.1729
Can you people please verify the correctness of this statement.
Thus before considering + which has the least priority, we get $A + (BCD+*F/) + (DE*)$
Now if we assume left associativity for $+$ (default), we get $ABCD+*F/ + DE*+$ but this is not among the options.
So, considering right associativity for $+$ we get $ABCD+*F/DE*++$
Correct Answer: $B$
@Anix7
you are getting this answer because u are giving more precedence to / than *
but remember "precedence is nothing in front of associativity" as * is coming earlier than /.
then u ll get ABCD+*F/+DE*+ as answer.
Can some one explain please how exactly (B) is answer here by drawing its tree.
it is 5 level stak and postfix is: ABCD+*F/+DE*+
This might be useful..
https://www.geeksforgeeks.org/stack-set-2-infix-to-postfix/
According to this answer should be : $ABCD+*F/+DE*+$
We are getting this answer because in the operator stack when $+$ is on the top of the stack and the next symbol is $+$ we are doing a pop operation which has to be done.
But in order to get one of the options as an answer we need to change the associativity of $+$ and when $+$ is on the top of the stack and the next symbol is $+$ we will do a push operation and hence we will get an expression : $ABCD+*F/DE*++$ which is leading to option $B$