Question: Java code, you only need to do the ArrayQueue and ListQueue two file. Do not do stack part. and also please provide your testcases or

 Java code, you only need to do the ArrayQueue and ListQueuetwo file. Do not do stack part. and also please provide yourtestcases or output. I will give you a thumb up private classNode { private int data; private Node next; public Node() { this(,

Java code, you only need to do the ArrayQueue and ListQueue two file. Do not do stack part. and also please provide your testcases or output. I will give you a thumb up

private class Node { private int data; private Node next; public Node() { this(, null); } public Node(int data, Node next) { this.data = data; this.next = next; } } 1 interface Queue Interface { 2 30 4. * Add an element to the back of the queue. 5 6 void enqueue(int value); 7 ge 9 * Remove and return the front element in the queue. 10 11 * If the user attempts to dequeue from an empty queue, igr 12 * request (i.e. make no changes to your queue) and return 13 */ 14 int dequeue(); 15 160 /* 17 * Return (but do NOT remove) the front element of the quel 18 19 * If the user tries to peek on an empty queue, ignore the 20 * request (i.e. make no changes to your queue) and return 21 */ 22 int peek(); 23 240 /* 25 * Returns true if the queue has no elements. 26 */ 27 boolean isEmpty(); 28 290 /* 30 * Returns the number of elements in the queue. 31 */ 32 int size(); 133 340 35 * Removes all elements from the queue. 36 37 void clear(); 38 } 1 erface StackInterface { 2 30 /* 4 * Add an element to the top of the stack. 5 6 void push(int value); 7 80 9 * Remove and return the top element in the stack. 10 11 * If the user attempts to pop an empty stack, ignore the 12 * request (i.e. make no changes to the stack) and return -1. 13 */ 14 int pop(); 15 160 17 * Return (but do NOT remove) the top element of the stack. 18 19 * If the user attempts to peek on an empty stack, ignore thel 20 * request (i.e. make no changes to the stack) and return -1. 21 */ 22 int peek(); 23 240 25 * Returns true if the stack has no elements. 26 27 boolean is Empty(); 28 296 /* 30 * Returns the number of elements in the stack. 31 */ 32 int size(); 33 340 * 35 * Removes all elements from the stack. 36 */ 37 void clear(); 38 Code Your job is to implement four different classes. Two of the classes represent the Stack ADT (abstract data type) and the other two represent the Queue ADT. As mentioned in class, many data structures are built on either arrays or linked structures. You will implement both types for both the Stack and the Queue and then compare the implementations. We will not specify all of the methods you must implement for these classes in this spec. Instead, we will provide interfaces with the starter code that you must implement. In addition to the methods from the interfaces, you must also override the toString and equals methods. Lastly, you must implement copy constructors for all of your classes. Our autograder calls these methods. If you don't write these methods, then the autograder won't compile, which gives you a zero on the project. ArrayStack.java - implement the StackInterface with a Stack backed by an array. ListStack.java - implement the StackInterface with a Stack backed by a linked list. Array Queue.java - implement the QueueInterface with a Queue backed by an array. ListQueue.java - implement the QueueInterface with a Queue backed by a linked list. You are not allowed to use any other data structures other than an array for the two Array classes. For the linked list classes, you can not use the Java Linked List class. Instead implement them like they were done in class, using a Node inner class and creating the linked list yourself. Remember that in order to implement an interface all you have to type is: public class ArrayStack implements StackInterface { You will then get a compile error because your ArrayStack will have unimplemented methods from the interface. Eclipse should provide a 'quick fix' when you hover over the red line indicating the error. This quick fix can provide all of the method headers which can save some time typing. The quick fix is 'Add unimplemented methods.' Remember that after you have implemented the interfaces you must also override the toString and equals methods, and write copy constructors for all of your classes. The toString method should return a string of the format: "{0,1,2,3,4,5)". Note that there are no spaces in the string. The autograder counts on this format so be sure to follow it. If there are no elements at all, then print "{}". This also does not include a space. In the above example, 'O' would be the bottom of the stack and '5' would be the top. If it were representing a queue, 'O' would be the next element to be dequeued (the front of the queue) and '5' would be the element most recently enqueued (the back of the queue). Two stacks are equal if their sizes and all of their elements are equal. Two queues are equal if their sizes and all of their elements are equal. Clarifications to Common Questions As (has been or will be) mentioned in class and the spec (in bold), you are not allowed to use any other data structures. That means you cannot use the Java LinkedList class or the Java ArrayList class or any other data structure. To put it simply, just implement the classes very similarly to how we did in lecture. At the very top of this spec, we listed the files that you need to turn in. You should not turn in any other files. This means you can't create a Node class in a separate file. Instead, make the Node class as a nested class as shown in lecture. If you believe you need any other classes, these must also be nested/inner classes

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!