Question: 2. Consider a binary min-heap data structure that supports the INSERT and EXTRACT-MIN operations. In summary, INSERT adds the element at the leftmost available position

 2. Consider a binary min-heap data structure that supports the INSERT

2. Consider a binary min-heap data structure that supports the INSERT and EXTRACT-MIN operations. In summary, INSERT adds the element at the leftmost available position in the last level of the heap, and performs upward swaps as needed. EXTRACT-MIN extracts the root, replaces it with the rightmost element in the last level of the heap, and performs downward swaps as needed. (See Chapter 6 of the textbook if you need a refresher.) INSERT and EXTRACT-MIN each take O(log n) in the worst case. [15pt.) (a) Show a potential function that results in an amortized cost of O(log n) for INSERT and O(1) for EXTRACT-MIN. (b) Fill out the following table to derive the amortized cost of INSERT and EXTRACT-MIN based on the potential function. Show your calculations. Operation Actual Cost AD Amortized Cost INSERT EXTRACT-MIN ? 2

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