843 views
1 1 vote

A * B ^ C + D becomes A B C ^ * D +

Here both the exponentiation and the multiplication must be done before the addition.

current symbol

operator stack

postfix string

1

A

A

2

*

*

A

3

B

*

A B

4

^

* ^

A B

5

C

* ^

A B C

6

+

+

A B C ^ *

7

D

+

A B C ^ * D

8

A B C ^ * D +

in 4 line here precedence of     *   greater than  ^    therefore  *  should be popped out   , i checked precedence table too ,  someone explain this thanks 

2 Answers

0 0 votes
Maybe you interpred wrongly please check precedence order again! ^ has always greater precedence than * ! and still you have doubt then associativity rule might be considered here.
0 0 votes
1.Precedence of Exponentiation operator is always greater than multiplication.

2.Exponentiation  is right associative

3.Multiplication is left associative

apply

this rules and finds an answer.
Position:
Show:

Related questions

1 1 vote
1 1 answer
622
622 views
sumit goyal 1 asked Jul 31, 2017
622 views
if i get A + [ (B+C) ] /G in infix and i want to convert it into postfix then what to do with sign [ should i push it into stack ??
0 0 votes
1 1 answer
1.8k
1.8k views
Piyush Kapoor asked Sep 24, 2015
1,823 views
Assume that the operators +,−,× are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^,×,+,−. The postfix expression corre...
0 0 votes
0 0 answers
1.3k
1.3k views
Mk Utkarsh asked Oct 20, 2018
1,343 views
Please convert it to postfix by using stack and explain in detailvoid (*bsd_signal(int sig, void (*func)(int)))(int);
0 0 votes
0 0 answers
1.3k
1.3k views
Radha mohan asked Dec 26, 2017
1,271 views
Sir it is given everywhere that time complexity of infix to postfix is O(1) but according to algorithm for some operators we have to traverse back the stack until we find...