To do:

  • You will create a Priority Queue using a Heap represented in an array. All was covered in lecture yesterday and one day before last week.

Needed:

  • You will need a Heap class that will keep the MAX values as the highest priority that will be removed from the heap first, and the smaller 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 heap.
  • The Heap class will need a method for removing items from the heap.
    • 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 level.......until you get to a level that starts with a null.
  • 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: 15, 5, 8, 4, 9, 22, 17, 6, 14

2.Print Heap

3.Remove two items from the heap.

4.Print Heap

5.Add the following 18, 12

6.Print Heap

7.Remove three items from the heap.

8.Print Heap

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.