in Programming in C retagged by
714 views
0 votes
0 votes
The maximum size of the operator stack when converting the following infix to postfix expression

a ^ b * c * d + e * f ^ g (assume that “^” has highest precedence and right associativity) and also output the postfix expression.
in Programming in C retagged by
714 views

3 Answers

2 votes
2 votes
Answer is 3

postfix expression ab^c*d*efg^*+
0 votes
0 votes

 maximum size of the operator stack = $6$

( + ( * ( ^

Refer this → https://gateoverflow.in/141728/infix-to-postfix-using-stack?show=201769#c201769

0 votes
0 votes
In the operator stack, we get maximum size for last three operators i.e. +,*,^  as in the stack "*" can be put above "+" and "^" can be put above "*" . ( in case of other operators in the same question, is not possible ).

Hence, the maximum size of operator stack is 3.