2,322 views
0 votes
0 votes

2 Answers

2 votes
2 votes

Given infix expression are$:2 + 3 - ( 6 * 7 ) $

now convert infix to postfix expression using operator stack, we get postfix expression$: 2 3 + 6 7 * - $ [Because, if associativity not given we take $'+' $ are left associative]

now postfix expression$: 2 3 + 6 7 * - $

Scan entire string from left to right, when any operator come, pop top two elements and perform an operation (let say result = pop2$+$po1) and then push back result into the stack. Repeat this step until string scanning is over. 

So,i got $(3)$ are stack configuration.

and if we take $'+'$  is right associative,then postfix expression are$: 2 3 6 7 * - + $  

So, I got $(2)$ are stack configuration.

 

edited by
0 votes
0 votes
I think it must be not possible stack configuration

 by taking * as high precedence , + and - have same precedence

now there are two cases it can be left as well as right so applying as left associative we get option 1 and 3 as we apply right associative we also get option 2

So option 4 must be wrong

Related questions

889
views
0 answers
0 votes
Mk Utkarsh asked Oct 20, 2018
889 views
Please convert it to postfix by using stack and explain in detailvoid (*bsd_signal(int sig, void (*func)(int)))(int);
2.6k
views
1 answers
0 votes
Ananya Jaiswal 1 asked Dec 12, 2017
2,634 views
Result for evaluating the following post fix105+606/*8-I'm confused whether it is correct postfix expression.
5.7k
views
1 answers
2 votes
Himanshu Goyal asked Jul 14, 2017
5,657 views
How is ans 15 for this question Please can anybody solve this
2.9k
views
1 answers
1 votes
JaiKumar Guwalani asked May 6, 2018
2,856 views
What is time and space complexity to evaluate postfix expression ?