Question: Question 4: A program needs two stacks of positive integers: one containing elements with values less than or equal to 1000 and the other containing

Question 4: A program needs two stacks of positive integers: one containing elements with values less than or equal to 1000 and the other containing elements with values larger than 1000. The total number of elements in the small-value stack and the large-value stack combined is never more than 500 at any time, but we cannot predict how many will be in each stack. (Initially both will be empty; later on the stacks could be evenly divided, or all the elements could be in the small-value stack, and so on.) For efficiency reasons, we want to implement both stacks using a single array of size 500. Can you think of a way to do this? (a) Sketch what this "double-stack" array would look like. Explain how push and pop operations would work, accordingly. (3 marks) (b) Describe the private member variables of such a "double-stack" array based class, give thei niial values, and explain how they are modified by push and pop operations. Coding is not required
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
