Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Consider the following stack of characters,where stack is allocated 8 memory cells. Stack:a,9,e,,,,,_, Give the contents of the stack at the end of the each operation given below: i).pop() ii).pop() iii).push(e) iv).push(1) v).pop() vi).push(i) vii).push(0) viii).pop() ix).push(o) x).push(u)
Posted
Updated 2-Nov-11 19:55pm
v2
Comments
Vivek Krishnamurthy 3-Nov-11 1:16am    
What is the question ?
P.Salini 3-Nov-11 1:25am    
dont repost your question
Peter_in_2780 3-Nov-11 1:51am    
He only recycled the title. Probably the name of the course he want us to do the homework for.
Legor 3-Nov-11 5:07am    
Choose another career

If you are going to post your homework, at least try to make it look like you have attempted to do something yourself!

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"
 
Share this answer
 
Stack stands for LIFO (Last in First Out).
So assuming a,9,e,,,,,_, a is at the bottom.
i).pop() //removes _
a,9,e,,_,,_,
ii).pop() //removes _
a,9,e,,_,,
iii).push(e) //adds e
a,9,e,,_,,e,
iv).push(1) adds 1
a,9,e,,_,,e,1,
v).pop()
a,9,e,,_,,e,
vi).push(i)
a,9,e,,_,,e,i,
vii).push(0)
a,9,e,,_,,e,i, (Not pushed as stack overflow)
viii).pop()
a,9,e,,_,,e,
ix).push(o)
a,9,e,,_,,e,o,
x).push(u)
a,9,e,,_,,e,i, (Not pushed as stack overflow)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900