Click here to Skip to main content
12,405,303 members (67,728 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Java
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 2-Nov-11 18:46pm
Updated 2-Nov-11 19:55pm
v2
Comments
Vivek Krishnamurthy 3-Nov-11 1:16am
   
What is the question ?
CodeHelper_PS 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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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?"
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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)
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 3 Nov 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100