Can both insert and findMin be implemented in constant time?
Read moreTextbook Solutions for Data Structures and Algorithm Analysis in Java
Question
Suppose we want to add the decreaseAllKeys() operation to the heap repertoire.The result of this operation is that all keys in the heap have their value decreasedby an amount . For the heap implementation of your choice, explain the necessarymodifications so that all other operations retain their running times anddecreaseAllKeys runs in O(1).
Solution
The first step in solving 6 problem number 38 trying to solve the problem we have to refer to the textbook question: Suppose we want to add the decreaseAllKeys() operation to the heap repertoire.The result of this operation is that all keys in the heap have their value decreasedby an amount . For the heap implementation of your choice, explain the necessarymodifications so that all other operations retain their running times anddecreaseAllKeys runs in O(1).
From the textbook chapter Priority Queues (Heaps) you will find a few key concepts needed to solve this.
Visible to paid subscribers only
Step 3 of 7)Visible to paid subscribers only
full solution