Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java Homework
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
Edited 2-Nov-11 19:55pm
v2
Comments
Vivek Krishnamurthy at 3-Nov-11 1:16am
   
What is the question ?
CodeHelper_PS at 3-Nov-11 1:25am
   
dont repost your question
Peter_in_2780 at 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 at 3-Nov-11 5:07am
   
Choose another career
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  
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  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 525
1 CPallini 505
2 George Jonsson 353
3 OriginalGriff 220
4 Pheonyx 218
0 OriginalGriff 4,813
1 CPallini 3,890
2 Sergey Alexandrovich Kryukov 3,274
3 George Jonsson 2,552
4 Gihan Liyanage 2,186


Advertise | Privacy | Mobile
Web02 | 2.8.140905.1 | Last Updated 3 Nov 2011
Copyright © CodeProject, 1999-2014
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