in DS edited by
727 views
2 votes
2 votes

There is given a infix expression:

                                                             ${\color{Red} {1}}$

$A+B\times C/\left ( \left ( D+E \right )+F\times G \right )$

While converting infix expression to postfix expression number of symbols in the stack at indicated ${\color{Red} {point-1}}$ infix expression (assume stack is initially empty) ______________


they told $5$, but is it correct? Can anyone give some explanation??

in DS edited by
by
727 views

3 Answers

1 vote
1 vote
Yes it is 5

4 Comments

how??
0
0
Can you give the explanation please.
0
0

I got  ABC*DE+FG*+/+ as postfix expression with stack size 6, please verify it.

0
0
i got 5
0
0
0 votes
0 votes

5 is right

2 Comments

I think it will be ABCxDE+FGx+/+

4
4
Please read the question. It clearly says that we have to do pop and push operation in operator stack till "Point 1" only. It means for last operator ")" we don't have to do the operation.
0
0
0 votes
0 votes

Answer should be 6. The symbol ‘(‘ can never be popped from the stack whatever may be the precedence level of scanned character. If the character is closing round bracket ( ')' ), pop out operators from operator's stack until we find an opening bracket ('(' ) .

Due to this reason, the operator stack will contain +/((+*.

If you count this, these operators total to 6 & hence the answer.

Related questions

8 votes
8 votes
5 answers
1