The instructions are on the top of the code. Code in JAVA
instructions: 1)throughout the code, there will be TODO task to complete (8 TODO task)
2) if needed, create helper and heapify methods
3) lastly, test what you added by added test cases in the driver (located at the bottom of the code)
3Complete the following class with given prototype/header of a priority heap Look for the TODO tasks and complete them You may need to create a few more helper methods and heapify methods 6 | + add more ?es? cases ?lto the driver to test your code 9 import java.util.*; 10 11 public class Qlleap
{ 12 13 /** a simple nested class to represent the key-value pair */ class Ttem 15 16 public K key; public V value; public Item (K key, V valuc) 18 19 20 21 this.keykey; this.valuevalue public String toString ) return "key:" + this.key "nValue:"+ this.value; 23 24 25 26 27 28 29 30 private int capacity; //the maximum heap before resize is needed //end of nested class //attributes private final int DEFAULT CAPACITY private int count.; 15; private ArrayT,ist > st.orage;//array used to store the items 32 //constructors public QHeap t /ew heap with default size 34 35 36 37 38 39 40 this.count0; /o item in the storage yet this. capacity = DEFAULT-CAPACITY; //create the storage this. storage = new ArrayList >(DEFAULT-CAPACITY) ; /**create a heap with a specific size / public QHeap (int requestsize) ( 42 4 3 this.count -0; /o item in the storage yet this.capacity requestSize; this.storagenew ArrayList >(this.capacity);//create the storage 4 5 4 6 4 7 48 copy constructor - copy the content of the given heap into a new one */ public QlHeap (Olleap given) 50 51 52 53 54 //TODO: copy the data of the given heap to the new heap 56 57 58 //methods / merge the given heap into this one / public int merge (QHeap second) //TODO: merge the heap here 3Complete the following class with given prototype/header of a priority heap Look for the TODO tasks and complete them You may need to create a few more helper methods and heapify methods 6 | + add more ?es? cases ?lto the driver to test your code 9 import java.util.*; 10 11 public class Qlleap{ 12 13 /** a simple nested class to represent the key-value pair */ class Ttem 15 16 public K key; public V value; public Item (K key, V valuc) 18 19 20 21 this.keykey; this.valuevalue public String toString ) return "key:" + this.key "nValue:"+ this.value; 23 24 25 26 27 28 29 30 private int capacity; //the maximum heap before resize is needed //end of nested class //attributes private final int DEFAULT CAPACITY private int count.; 15; private ArrayT,ist > st.orage;//array used to store the items 32 //constructors public QHeap t /ew heap with default size 34 35 36 37 38 39 40 this.count0; /o item in the storage yet this. capacity = DEFAULT-CAPACITY; //create the storage this. storage = new ArrayList >(DEFAULT-CAPACITY) ; /**create a heap with a specific size / public QHeap (int requestsize) ( 42 4 3 this.count -0; /o item in the storage yet this.capacity requestSize; this.storagenew ArrayList >(this.capacity);//create the storage 4 5 4 6 4 7 48 copy constructor - copy the content of the given heap into a new one */ public QlHeap (Olleap given) 50 51 52 53 54 //TODO: copy the data of the given heap to the new heap 56 57 58 //methods / merge the given heap into this one / public int merge (QHeap second) //TODO: merge the heap here