Question: 4: 7: 8: 1: function Func(A[],n) 2: P. Init() 3: for i = 1 to [log3(n)] do for j = 1 to n do 5:

 4: 7: 8: 1: function Func(A[],n) 2: P. Init() 3: for

4: 7: 8: 1: function Func(A[],n) 2: P. Init() 3: for i = 1 to [log3(n)] do for j = 1 to n do 5: P. Insert(A[i] > A[j]) 6: end for I = P.ExtractMax() Print(2) 9: end for 10: end function P.Init() initializes the data structure P.Insert (1) inserts elements r into P. P. ExtractMax() returns the maximum element of P and deletes it from P. P.Size() returns the number of elements in P. Hint: Express the number of elements in terms of i and j! The typed notes go through this in a lot more detail than the video lectures! (a) Analyze the running time of the given algorithm assuming that P is implemented using a Max-Heap. Note that the time for P. Insert() and P. Extract Max() are both dependent on the number of elements in P. which changes over the running time of the algorithm. Assume that P.Init() and P.Size() operations take constant time

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!