Question: 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
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
Get step-by-step solutions from verified subject matter experts
