Question: The Max-Heap data structure is often used to implement a priority queue in applications. Some applications may need to change the priority (stored as a
The Max-Heap data structure is often used to implement a priority queue in applications. Some applications may need to change the priority (stored as a value) of a specific node i. That is, given a node index i, we need to change the priority of node i to a new priority t. Please write the pseudo-code for this procedure Max-Heap-Update(A, i, t). Note that the new key can be smaller or bigger. What is the worst-case run-time for your procedure? (Hint: Max-Heap-Increase-Key already does the case when the key is increased, so we can reuse that procedure. How do we handle the case if the key is decreased? Can you reuse Max-Heapify?)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
