Question
Implement a priority queue as a linked list based data structure using provided Node class below. LinkedPriorityQueue class 1. Fields: An array of nodes named
Implement a priority queue as a linked list based data structure using provided Node class below.
LinkedPriorityQueue class 1. Fields: An array of nodes named rears; stores the tail of the priority groups as subarrays; if a priority group is empty, its rear reference is null. front; the head reference of the entire linked list
Constructor initializes rear array
*******************************************
Would really just like help with the constructor and the overall layout of the class. Confused by the rears array of nodes. Please do not use
any of Java's built in classes (LinkedList class, LinkedQueue, Queue interface, PriorityQueue class...etc)
*******************************************
MY NODE CLASS
public class Node implements Cloneable {
private String data;
private Node link;
public Node getLink() {
// reference to node after this node
return link;
}
public String getData() {
return data;
}
public void setData(String newData) {
data = newData;
}
public Node( String initialData, Node initialLink) {
data = initialData;
link = initialLink;
}
public Node addNodeAfter(String element) {
link = new Node(element, link);
return link;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started