• retagged by
24,163 views
55 55 votes
Compute the post fix equivalent of the following expression $3^*\log(x+1)-\frac{a}{2}$

9 Answers

Best answer
118 118 votes
The priority of the operators follows the usual conventions:
  • The highest priority is assigned to unary operators (note that, in this context, a function such as sin  is considered a unary operator). All unary operators have the same priority.
  • Exponentiation has the second highest priority.
  • The third highest priority is assigned to the multiplication and division operators.
  • The lowest priority is given to the addition and subtraction operators. 
Example:->>
Infix expression:   $3  * \log(  10  )$
Postfix expression:
$=3  *   (10 \log)$   //(Priority of unary operator log forces $\log( 10 )$ to evaluate first.)
$=3  \ 10  \log  *$

Now for our case $3*\log(x + 1) - a / 2$

First content inside parenthesis will be evaluated

So, $x+1$ will become $x\;1+$

Now among $(*,/,\log,+,-)$ operators, $\log$ has highest priority as it is the only unary operator

So, $\log(x\;1+)$ will become ${x\;1+\log}$

Now suppose ${z= x1+\log}$ and we get  $3* z - a / 2$

$\implies 3z* a\;2/ -$

Now, substitute $z= x\;1+\log$ and we get

$\mathbf{3x\;1+\log*  a\;2/  -}$ as answer.

• edited by
23 23 votes

We can do directly(manually) =>

3*log(x + 1) - a / 2

= ((3*(log(x + 1))) - (a / 2))

= ((3*log(x1+))) - (a2/))

= ((3*x1+log) - (a2/))

= ((3x1+log*) - (a2/))

= 3x1+log*a2/- 

13 13 votes
$3 x 1 + \log * a 2 / -$
13 13 votes

Given infix expression : $3*log(x+1)- \frac{a}{2}$

Expression tree :

Do a postorder traversal of the above tree to get postfix expression: $3x1+log*a2/-$

Position:
Show:

Related questions

4 4 votes
2 2 answers
698
698 views
Shubham Sharma 2 asked Sep 10, 2025
698 views
Consider the following infix expression $Q:\left((A+B)^{*} D\right) \uparrow(E-F)$. The equivalent postfix expression of $Q$ is$A B+D ^{*} E F \uparrow$ -$A B+D^{*}-\upar...
3 3 votes
3 3 answers
1.8k
1.8k views
soujanyareddy13 asked Mar 25, 2021
1,828 views
What is the prefix expression corresponding to the expression:$\left ( \left ( 9+8 \right ) \ast 7+\left ( 6\ast \left ( 5+4 \right ) \right )\ast 3\right )+2?$You may as...
0 0 votes
1 1 answer
1.6k
1.6k views
go_editor asked Mar 26, 2020
1,626 views
If the postfix form of a string is $ABC +$ $– D^{*}$, the actual string is :$\left ( A-\left ( B+C \right ) \right )^{*}D$$\left ( \left ( A-B \right )+C \right )^{*}D$$\...
0 0 votes
0 0 answers
484
484 views
gatecse asked Aug 4, 2019
484 views
The postfix notation for infix notation $a^*(b+c)+d÷e$ is given by$abc^*+de ÷ +$$abc+^*de ÷ +$$abcde +^*÷ +$$abc^*+de + ÷$