Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following program: P Initialize() initializes the data structures. P Insert (a) inserts elements a in P P Extract Max returns the maximum element

image text in transcribed
Consider the following program: P Initialize() initializes the data structures. P Insert (a) inserts elements a in P P Extract Max returns the maximum element of P and deletes it from P. P Size() returns the number of elements in P (a) Analyze carefully the running time of Program2 assuming that P is implemented as a Max-Heap. Analyze the total time for both the PInserto and PExtractMaxO operations. Note that the time for P. Insert and P.ExtractMaxO is dependent on the number of elements in P which changes over the running time of the algorithm. Operations P.InitializeO and P.SizeO take Show your work. (b) Analyze carefully the running time of Program assuming that P is implemented by some data structure which takes Theta (squarerrot x) time for P.Inserto where s is the number of elements in P and e(1) time for P.ExtractMaxO. Analyze the total time for both the P.Inserto and P.ExtractMaxO operations. Note that the time for P-Inserto is dependent on the number of elements in P

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

Step: 3

blur-text-image

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

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions