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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started