Question: Consider the following program: P. Initialize() initializes the data structures. P. Insert (z) inserts elements in P. P. ExtractMax() returns the maximum element of P
Consider the following program: P. Initialize() initializes the data structures. P. Insert (z) inserts elements in P. P. ExtractMax() 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 Program1 assuming that P is implemented as a Max-Heap. Analyze the total time for both the P.InsertO and P.ExtractMaxO operations. Note that the time for P Insert and P.ExtractMax is dependent on the number of elements in P which changes over the running time of the algorithm. Operations P.InitializeC) and P.Sizeo take constant time. Show your work. (b) Analyze carefully the running time of Programi assuming that P is implemented by some data structure which takes Theta(s^2/3) time for P.Innert O where s is the number of elements in P and e(1) time for P.ExtractMaxC). Analyze the total time for both the P.Insert and P.ExtractMax() operations. Note that the time for P.Insert C) is dependent on the number
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
