Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with this Java Data Structures Assignment. Thanks Linked Queue Class

ID: 3816295 • Letter: I

Question

I need help with this Java Data Structures Assignment. Thanks

Linked Queue Class - You will write the LinkedQueue.java class which will implement the Queue Interface. Please note that Queue Interface extends the Iterable Interface. Also note that the Linked Queue Class should be a Doubly Linked Queue.

Element Iterator Class - You will write the ElementIterator.java class which will implement the Iterator Interface.

Node Class - You will write the Node.java. Please note that the Node Class is a node for a Doubly Linked Queue.

Queue Interface Methods

Iterable Interface Method

Iterator Interface Methods

Node Class

Interface Queuelnterface

Explanation / Answer

class LinkedQueue <Item> implements Queue <Item>
{
private Node front, rear;
private int size;
private class Node
{
Item item;
Node next;
}
public LinkedQueue()
{
front = null;
   rear = null;
size = 0;
}
public boolean isEmpty()
{
return (size == 0);
}
public Item delete()
{
Item item = front.item;
front = front.next;
if (isEmpty())
{
rear = null;
}
size--;
return item;
}
public void insert(Item item)
{
Node oldRear = rear;
rear = new Node();
rear.item = item;
rear.next = null;
if (isEmpty())
{
front = rear;
}
else
{
oldRear.next = rear;
}
size++;
}
public int size()
{
return size;
}
}