Question: Implement Adaptable Priority Queues using a Heap. Construct the Heap using the ArrayList data structure. A class file named HeapPQ has been provided for your
Implement Adaptable Priority Queues using a Heap. Construct the Heap using the ArrayList data
structure. A class file named HeapPQ has been provided for your convenience. It's essential to implement
all the methods within this file, including the upheap and downheap methods. Take note that HeapPQ
is designed to implement an Adaptable PQ not merely a PQ
Please fill out the fowlling code and leave comments:
package csc;
import java.util.Comparator;
import net.datastructures.;
public class HeapPQ implements AdaptablePriorityQueue
use default comparator, see DefaultComparator.java
public HeapPQ
TODO: implement this method
use specified comparator
public HeapPQComparator c
TODO: implement this method
Return the data array that is used to store entries
This method is purely for testing purpose of autograder
Object data
TODO: replace the line below to return the actual array
return null;
The entry should be bubbled up to its appropriate position
@param int move the entry at index j higher if necessary, to restore the heap property
public void upheapint j
TODO: implement this method
The entry should be bubbled down to its appropriate position
@param int move the entry at index j lower if necessary, to restore the heap property
public void downheapint j
TODO: implement this method
@Override
public int size
TODO Autogenerated method stub
return ;
@Override
public boolean isEmpty
TODO Autogenerated method stub
return false;
@Override
public Entry insertK key, V value throws IllegalArgumentException
TODO Autogenerated method stub
return null;
@Override
public Entry min
TODO Autogenerated method stub
return null;
@Override
public Entry removeMin
TODO Autogenerated method stub
return null;
@Override
public void removeEntry entry throws IllegalArgumentException
TODO Autogenerated method stub
@Override
public void replaceKeyEntry entry, K key throws IllegalArgumentException
TODO Autogenerated method stub
@Override
public void replaceValueEntry entry, V value throws IllegalArgumentException
TODO Autogenerated method stub
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
