edited by
4,204 views
0 votes
0 votes

The minimum size of stack required to evaluate given post fix expression is _____________

postfix :- 2 5 x 6 + 4 2 x -

 

MY ANSWER IS 8..

CAN ANYONE TELL ME WHERE I AM WRONG…??

edited by

1 Answer

Best answer
1 votes
1 votes
Ans is 3.

3 is the minimum stack size required. This is how..

First you will push 2 ... Stack size becomes 1

Then you will push 5 ... Stack size becomes 2

On seeing x, you pop 2 numbers from stack and push back the result... Stack size becomes 1

Then push 6.. stack size becomes 2

Then on +, 2 pops and then 1 push.. stack size is 1 now

Then on on seeing 4,2 they are pushed onto stack.. stack size becomes 3

Then eventually as expression is further evaluated stack size dwindles down to 0.

So to evaluate expression, stack size should be atleast 3.
selected by
Answer:

Related questions

1 votes
1 votes
0 answers
1
Nidhi Budhraja asked Aug 26, 2018
374 views
How do I set deadlines and plan for gate 2019 as I am behind the schedule given by Arjun sir in go classroom ( I have completed discrete maths till now)?
0 votes
0 votes
1 answer
2
bts asked Jul 3, 2018
662 views
Is the chapter Complex functions part of gate 2019 maths syllabus?Previously questions about analytic functions have been asked a lot. Are they part of the syllabus?
–2 votes
–2 votes
0 answers
3
J Kargo 2 asked Jul 1, 2018
342 views
0 votes
0 votes
1 answer
4
Sivarama Subramanian asked Jun 2, 2018
12,182 views
Where can I find the GO book pdf for GATE 2019 ?If possible please add the link for downloading the pdf.