Results 1 to 6 of 6
Thread: 2 Stacks in a linear array
- 06-11-2011, 08:32 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 78
- Rep Power
- 0
2 Stacks in a linear array
I need some help with this homework assignment:
Design a method for keeping two stacks within a single linear array s[SPACESIZE] so that neither stack overflows until all of memory is used and an entire stack is never shifted to a different location within the array. Write Java methods push1, push2, pop1, and pop2 to manipulate the two stacks. (the two stacks grow toward each other.)
-
Please show us what you've done so far, and then ask a specific question that we can answer.
- 06-11-2011, 09:36 PM #3
Member
- Join Date
- Feb 2011
- Posts
- 78
- Rep Power
- 0
Since a stack is virtually not limited by size, if I am going to use an array to manage 2 stacks, I have to initialize the stack to some value, so I picked 5000
- 06-11-2011, 09:37 PM #4
Member
- Join Date
- Feb 2011
- Posts
- 78
- Rep Power
- 0
Array<E> myArray;
Last edited by fam2315; 06-11-2011 at 10:30 PM.
-
I imagine that one stack will need to start at the floor of the array and grow up and the other stack will start at the roof of the array and grow down, and you will need two int index variables to represent the current location of the top of each stack, taking care that one index does not pass the other.
- 06-11-2011, 10:29 PM #6
Member
- Join Date
- Feb 2011
- Posts
- 78
- Rep Power
- 0
Similar Threads
-
Linear Search
By Teclis in forum New To JavaReplies: 19Last Post: 04-20-2011, 05:28 AM -
problem with linear search
By Metastar in forum New To JavaReplies: 14Last Post: 09-14-2010, 08:01 PM -
linear systems of equations
By tyang in forum New To JavaReplies: 2Last Post: 03-24-2010, 03:13 PM -
Sorting an Array via Stacks
By viperlasson in forum New To JavaReplies: 0Last Post: 02-01-2010, 06:53 AM -
Help me(Linear Multiobjective programming)
By vinaytvijayan in forum Advanced JavaReplies: 2Last Post: 01-22-2008, 07:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks