Question: 6. (17 points total) Imagine using a doubly linked list to implement the queue ADT for values of type int. Skeleton code is provided below.

6. (17 points total) Imagine using a doubly linked list to implement the queue ADT for values of type int. Skeleton code is provided below. Implement the enqueue and dequeue methods. Instead of using the methods of the List ADT, manipulate the nodes directly. You have access to the head and tails nodes directly. This doubly linked list uses sentinel nodes and you can assume that head and tail have already been initialized properly.

class LinkedListQueue {

private static class Node {

Node prev;

Node next;

int data;

}

Node head;

Node tail;

public enqueue(int x) { // write this};

public int dequeue() { // write this};

}

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!