Question: public class QueueArrayBased implements Queue { ArrayList list; public QueueArrayBased() { list = new ArrayList (); } /** * when need to resize the running

public class QueueArrayBased implements Queue {
ArrayList list; public QueueArrayBased() { list = new ArrayList(); }
/** * when need to resize the running time is O(size of queue) */ public void enqueue(T item) { list.add(item); // adds to the end of the array } /** * running time is O(size of queue) */ public T dequeue() { return list.remove(0); // remove from position 0 } public boolean isEmpty() { return list.size()==0; } }
public class QueueLinkedListBased implements Queue {
LinkedList list; public QueueLinkedListBased() { list = new LinkedList(); } public void enqueue(T item) { list.addLast(item); } public T dequeue() { return list.removeFirst(); } public boolean isEmpty() { return list.size()==0; } }
Part 2 class MyQueueOperations T> The interface Queue declares the standard operations: enqueue(), dequeue(), isEmpty(). You have two concrete implementations: QueueArrayBased.java and QueueLinkedListBased.java Your goal is to implement the class MyQueueOperations. The class has several public static methods manipulating Queue. The public methods are as follows. public static T int size (Queue Tq ) Returns the number of elements in q. public static T Queue T clone (Queue orig) Returns a copy of orig. The items are copied from orig to the new queue using = operator. For the concrete type of the returned object, you may use either QueueArrayBased or QueueLinkedListBased. That's up to you. public static T void reverse (Queue q) Reverses the order of the elements in q. public static T boolean areEqual (Queue Tq1, Queue T q2) Checks if the two queues have the same items in the same order. The items in the queues are to be compared using == operator. After the methods return, the input queues must be in the same state as in the beginning