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. 0. Use the code from class / Canvas as a starting point or start yourself from scratch to create a class MinHeap with generic key-value entries. 1. 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 2 Symbol Table as example code or read the Java documentation on how to define generic types. 2. Create a constructor which initializes the attribute A (array) from a provided list. Make sure you use the actual heap array starting with index 1 so it aligns with our textbook. Copy the methods left, right, and parent from class code. 3. Write a method void heapify(int index) which creates a min-heap recursively. Recall that keys cannot be compared with < or > if the type is not known at compile-time, so use a comparator as we did in week 2 (where left

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