Question: In class we implemented a max heap s heapify method in Java for generic keys, but lacking values. For this assignment , you will implement
In class we implemented a max heaps heapify method in Java for generic keys, but lacking values. For this assignment you will implement methods as outlined below in Java. Use the code from class Canvas as a starting point or start yourself from scratch to create a class MinHeapwith generic keyvalue entries. Create a class Data with generic attributes key and value of generic type. Define your MinHeap class such that it uses array members of type Data, but ordering will occur by an entrys attribute key. You will need to declare your key type to be comparable. Use the Week Symbol Table as example code or read the Java documentation on how to define generic types. Create a constructor which initializes the attribute A array from a provided list. Make sure you use the actual heap array starting with index so it aligns with our textbook. Copy the methods left, right, and parentfrom class code. Write a method void heapifyint index which creates a minheap recursively. Recall that keys cannot be compared with or if the type is not known at compiletime, so use a comparator as we did in week where left
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
