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 csc311;
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 HeapPQ(Comparator c){
//TODO: implement this method
}
/*
* Return the data array that is used to store entries
* This method is purely for testing purpose of auto-grader
*/
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 upheap(int 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 downheap(int j){
//TODO: implement this method
}
@Override
public int size(){
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isEmpty(){
// TODO Auto-generated method stub
return false;
}
@Override
public Entry insert(K key, V value) throws IllegalArgumentException {
// TODO Auto-generated method stub
return null;
}
@Override
public Entry min(){
// TODO Auto-generated method stub
return null;
}
@Override
public Entry removeMin(){
// TODO Auto-generated method stub
return null;
}
@Override
public void remove(Entry entry) throws IllegalArgumentException {
// TODO Auto-generated method stub
}
@Override
public void replaceKey(Entry entry, K key) throws IllegalArgumentException {
// TODO Auto-generated method stub
}
@Override
public void replaceValue(Entry entry, V value) throws IllegalArgumentException {
// TODO Auto-generated method stub
}
}

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 Programming Questions!