Question: Please solve this ASAPPART 1 - An extended max heap operation A max heap is useful to implement another data structure Priority Queue, where you

Please solve this ASAPPART 1- An extended max heap operation
A max heap is useful to implement another data structure Priority Queue, where you can always
have the highest priority value at the root of the heap, so that the system can easily gain access
to the most imminent task at a time.
In case we want to force the system to handle a certain task sooner, we might need to increase
a certain priority value inside the max heap while still maintaining the max heap property. For
this reason we may introduce the Heap-Increase routine, which is defined as:
Heap-Increase (A, i, k)
Given a max heap array A(of size n), Heap-Increase (A, i, k) increases A[i] by k.
A. How would you heapify the now changed heap array after A[i] is increased? How would
you mitigate potential max-heap violations? To answer this question, you may either -
Show your implementation of Heap-Increase using the following pseudocode
template;
or explain the mechanism in plain English, in no more than 4 full sentences. (6pts)
Hint: Recall the strict premise in order to apply Max-Heapify and how we do Build-Heap
from ground up.
B. And what is the Big-O-of-n time complexity of your Heap-Increase routine?
(4pt) Hint: There are two acceptable answers, depending on how you implement it in A.
Heap-Increase(A, i, k)
A[i]= A[i]+ k; //assuming k is always positive
// And then?
Please solve this ASAPPART 1 - An extended max

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