Question: I have to make a priority class using a heap class I already have built. I am having all the issues with the priority queue
I have to make a priority class using a heap class I already have built. I am having all the issues with the priority queue since I havent made that many. I also have a class for Node but again unsure about.
class PriorityQueue extends Heap{ public PriorityQueue(int maxSize){ Heap priorityQueue = new Heap(maxSize); } public void insert(Node newNode){ } public Node extract(){ } public void changeKey(int i, int k){ } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class Node implements Comparable
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class Heap{ protected Node[] heapArray; protected int heapsize; protected int[] loaction;
public Heap(){ heapArray = new int[20]; } public Heap(int n){ heapArray = new int[n]; } public int right(int i){ return i*2+2; } public int left(int i){ return i*2+1; } public void maxHeapify(int i){ int left = left(i); int right = right(i); int largest = i; if(left
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
