Part-1(Java) Create a doubly linked list based DeQueDLL class that implements the DequeInterface. The class skeleton and interface are provided to you. Implement a String toString () method that...



Part-1(Java)



  1. Create a doubly linked list based DeQueDLL class that implements the DequeInterface. The class skeleton and interface are provided to you.

  2. Implement a String toString () method that creates and returns a string that correctly represents the current deque. Such a method could prove useful for testing and debugging the class and for testing and debugging applications that use the class. Assume each queued element already provides its own reasonable toString method.


Skeleton:


import ch04.queues.*;
import support.DLLNode;


public class DeQueDLL implements DequeInterface {


protected DLLNode front, rear; // reference to the front and rear of this deque
protected int numElements = 0; // number of elements in this deque


public DeQueDLL() {
front = null;
rear = null;
}


public void enqueueFront(T element) {
// TODO Auto-generated method stub


}


public void enqueueRear(T element) {
// TODO Auto-generated method stub


}


public T dequeueFront() throws QueueUnderflowException {
// TODO Auto-generated method stub
return null;
}


public T dequeueRear() throws QueueUnderflowException {
// TODO Auto-generated method stub
return null;
}


public boolean isFull() {
// TODO Auto-generated method stub
return false;
}


public boolean isEmpty() {
// TODO Auto-generated method stub
return false;
}


public int size() {
// TODO Auto-generated method stub
return 0;
}


}



import ch04.queues.QueueOverflowException;
import ch04.queues.QueueUnderflowException;


public interface DequeInterface
{
void enqueueFront(T element) throws QueueOverflowException;
// Throws QueueOverflowException if this queue is full;
// otherwise, adds element to the front of this queue.


void enqueueRear(T element) throws QueueOverflowException;
// Throws QueueOverflowException if this queue is full;
// otherwise, adds element to the rear of this queue.


T dequeueFront() throws QueueUnderflowException;
// Throws QueueUnderflowException if this queue is empty;
// otherwise, removes front element from this queue and returns it.


T dequeueRear() throws QueueUnderflowException;
// Throws QueueUnderflowException if this queue is empty;
// otherwise, removes rear element from this queue and returns it.


boolean isFull();
// Returns true if this queue is full; otherwise, returns false.


boolean isEmpty();
// Returns true if this queue is empty; otherwise, returns false.


int size();
// Returns the number of elements in this queue.


}


Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here