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 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<T> implements DequeInterface<T> {protected DLLNode<T> front, rear; // reference to the front and rear of this dequeprotected 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 stubreturn null;} public T dequeueRear() throws QueueUnderflowException {// TODO Auto-generated method stubreturn null;} public boolean isFull() {// TODO Auto-generated method stubreturn false;} public boolean isEmpty() {// TODO Auto-generated method stubreturn false;} public int size() {// TODO Auto-generated method stubreturn 0;} }   import ch04.queues.QueueOverflowException;import ch04.queues.QueueUnderflowException; public interface DequeInterface<T>{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. }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18SA
icon
Related questions
icon
Concept explainers
Question

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<T> implements DequeInterface<T> {

protected DLLNode<T> 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<T>
{
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.

}

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning