Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started