This is all part of 1 assignment. What i need the most is the final output. Thank you.
This assignment has three parts: 1) Implementing a queue data structure using a circular array, 2) implementing a queue data structure using two stacks, and 3) comparing the running times of "enqueue" and "dequeue" operations of both implementations in two given scenarios. 1 Constructing CAQueue: a Queue using a Circular Array As mentioned in the textbook and the slides, you can implement a queue using a circular array. In this implementation, CAQueue is a Java class with two key methods: enqueue and dequeue and two main private instance fields front and back storing the indices of front and back objects in the circular array. You must use an object of type java.util. ArrayList as the underlying data structure which stores the objects in the queue. 2 Constructing SSQueue: a Queue using two Stacks In this part. you need to first implement the java class MyStack and its push and pop methods to store/remove objects in a First-In-Last-Out manner to/from an object of type java.util.ArrayList. Then, you should implement the class SsQueue and its enqueue and dequeue operations using two stacks of type MyStack in the following way: The enqueue operation can be done by simply pushing the explicit input parameter of the method in the first stack. The dequeue operation pops an element from the second stack. If the second stack is empty, but the first one is not empty, you need to transfer all of the elements stored in the first stack to the second one. After emptying the first stack, you simply pop one 2 Constructing SSQueue: a Queue using two Stacks In this part, you need to first implement the java class MyStack and its push and pop methods to store/remove objects in a First-In-Last-Out manner to/from an object of type java.util. ArrayList. Then, you should implement the class SSQueue and its enqueue and dequeue operations using two stacks of type MyStack in the following way: The enqueue operation can be done by simply pushing the explicit input parameter of the method in the first stack. The dequeue operation pops an element from the second stack. If the second stack is empty, but the first one is not empty, you need to transfer all of the elements stored in the first stack to the second one. After emptying the first stack, you simply pop one element from the second stack to complete the dequeue operation. 3 Efficiency Comparison of two Implemented Queues In this part, you need to write a program that compares the efficiency of the queue imple- mentations in parts 1 and 2. To do so, you need to find and compare the running times of the following two scenarios for both queue implementations: 3.1 Scenario 1: Alternating Sequence of Enqueues and Dequeues For every n e {20,50, 100, 1000, 10000, 100000, 1000000), do the following: 1. long start Time = System.nanoTime(); 2. add the first n non-negative integers to the queue. 3. for every i {0,1,...,n-1}, do the following: (a) enqueue(i + n) (b) dequeuel) 4. long end Time = System.nanoTime(); 5. long totalTime = endTime - start Time: 6. System.out.println(n + ", " + totalTime) 3.2 Scenario 2: Random Sequence of Enqeueus and Dequeues For every n = {20,50.100, 1000, 10000 100000, 1000000}, do the following: 1. long start Time = System.nano Time(); 2. add the first non-negative integers to the queue 3.2 Scenario 2: Random Sequence of Enqeueus and Dequeues For every n e {20, 50, 100, 1000, 10000, 100000, 1000000}, do the following: 1. long start Time = System.nano Time(); 2. add the first n non-negative integers to the queue. 3. for every i E {0,1,...,n-1}, do the following: (a) if (Math.random()