482 views
2 votes
2 votes

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 votes
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 votes
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.

Related questions

2 votes
2 votes
1 answer
1
sumit goyal 1 asked Jul 31, 2017
340 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 votes
0 votes
0 answers
3
Mk Utkarsh asked Oct 20, 2018
827 views
Please convert it to postfix by using stack and explain in detailvoid (*bsd_signal(int sig, void (*func)(int)))(int);
0 votes
0 votes
0 answers
4
Radha mohan asked Dec 26, 2017
1,040 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...