1,906 views
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))

2 Answers

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+*+
selected by
0 votes
0 votes
infix to postfix conversion

here postfix expression will be PQ+RS+*T/ABC+*+

Maximum size of stack is 5
edited by

Related questions

451
views
1 answers
0 votes
_xor_ asked May 29, 2015
451 views
4.2k
views
3 answers
0 votes
radha gogia asked Jul 22, 2015
4,203 views
According to me when we perform the above operations we have to traverse the entire list so then why does it all take constant time ?
2.9k
views
2 answers
0 votes
radha gogia asked Mar 7, 2016
2,860 views
The hash function is randomly chosen from a universal class of hash functions , then what is the probability of any collision ?
564
views
1 answers
0 votes
sh!va asked Dec 6, 2016
564 views
Interview Question:1) How size of a stack and heap memory for a proces is decided?2) I wrote a program with no data or instructions. How text, data, stack ,heap will be allocated for corresponding process?main(){/*No instructions*/}