0 votes 0 votes Consider the following infix expression which is to be converted to postfix expression using stack. (((P+Q)*(R+S))/T)+(A*(B+C)) gshivam63 asked Jun 2, 2016 gshivam63 1.9k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 4 votes 4 votes Incoming Symbols Stack Output Postfix ( ( ( (( ( ((( P ((( P + (((+ P Q (((+ PQ ) (( PQ+ * ((* PQ+ ( ((*( R ((*( PQ+R + ((*(+ S ((*(+ PQ+RS ) ((* PQ+RS+ ) ( PQ+RS+* / (/ T (/ PQ+RS+*T ) PQ+RS+*T/ + + ( +( A +( PQ+RS+*T/A * +(* ( +(*( B +(*( PQ+RS+*T/AB + +(*(+ C +(*(+ PQ+RS+*T/ABC ) +(* PQ+RS+*T/ABC+ ) + PQ+RS+*T/ABC+* PQ+RS+*T/ABC+*+ vijaycs answered Jun 2, 2016 • selected Jun 2, 2016 by srestha vijaycs comment Share Follow See all 3 Comments See all 3 3 Comments reply gshivam63 commented Jun 2, 2016 reply Follow Share According to above explanation size of the stack is 5 not 6. But the correct answer given is 15.. How 15 can be the answer I think it should be 5?? 1 votes 1 votes srestha commented Jun 2, 2016 reply Follow Share yes it should be 5 0 votes 0 votes arya_stark commented Jul 4, 2018 reply Follow Share 15 is sum of all unique possible heights of stack. 1+2+3+4+5 = 15 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes infix to postfix conversion here postfix expression will be PQ+RS+*T/ABC+*+ Maximum size of stack is 5 srestha answered Jun 2, 2016 • edited Jun 2, 2016 by srestha srestha comment Share Follow See all 0 reply Please log in or register to add a comment.