Question: Java netbeans Question 2 (5 marks) Consider the following two classes ArrayStack and ArrayQueue: class ArrayStack t private intl] data; private int t -1; public

Java netbeans
 Java netbeans Question 2 (5 marks) Consider the following two classes

Question 2 (5 marks) Consider the following two classes ArrayStack and ArrayQueue: class ArrayStack t private intl] data; private int t -1; public ArrayStack (int capacity) public int size) public boolean isEmpty) public void push (int e)t public int top) public int pop () public String toString) ( class ArrayQueue public static final int CAPACITY 1000; private intl] data; private int front 0; private int qsize 0; public ArrayQueue) ) public ArrayQueue (int capacity) public int size) public boolean isEmpty(O public void enqueue (inte) public int first) public int dequeue) public String tostring)f Write a method mergeStacks ( that takes as parameters two stacks S and T. Using a queue Q, it should merge the content of T in S, so that S stores all the elements of T below all of its original elements, with both sets of elements still in their original order. Example Content of S: (6 2 4) Content of T: (7 3 5 9) Content of S after merging S and T: (6 2473 5 9) 9

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!