Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions

Question

=+6 Who is the peer of the IA ?

Answered: 1 week ago

Question

=+herself to in terms of equity with regard to this assignment?

Answered: 1 week ago

Question

=+ What typical employee will the IA compare him/

Answered: 1 week ago