Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java To do: You will create a Priority Queue using a Heap represented in an array. All was covered in lecture last Mondaydo not use

image text in transcribed

Java

To do: You will create a Priority Queue using a Heap represented in an array. All was covered in lecture last Mondaydo not use the Java API for this, implement it yourself just like I did in class. Needed: You will need a Heap class that will keep the MININUM values as the highest priority that will be removed from the heap first, and the larger numbers with less priority The Heap class will need an instance field array that holds ints, you can just make the array size 25 and we'll make sure we don't go over 25 elements. . The heap class will need a method for inserting items in the heajp The Heap class will need a method for removing items from the heap o Both methods will need to handle rearranging the items in the heap The Heap class will need a method for printing out the heap level by leve..until you get to a level that starts with a null. See if you can format it to look like a tree shape, the top will need to be centered (the pretty tree isn't a requirement) (Do this last) . A Driver class that sends in the ints to be stored in the heap Implementation, run these steps in order 1. Add the following items to your heap: 12, 45, 21, 5, 21, 10, 3, 55, 15 2. Print Heap (loop that prints the arrray, in order of Array) 3. Remove two items from the heap 4. Print Heap 5. Add the following 32, 6 6. Print Heap 7. Remove three items from the heap 8. Print Heap

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_2

Step: 3

blur-text-image_3

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions