Answered step by step
Verified Expert Solution
Link Copied!

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. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

2. Place a value on the outcomes.

Answered: 1 week ago