Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

8: 1: function Func(A[],n) 2: P.Init() 3: for i=1 to n do 4: for j = 1 to [log3(n)] do 5: P.Insert(A[i] > A[j]) 6: end for 7: end for for i = 1 to [n] do 9: I = P.ExtractMax() 10: Print : 11: end for 12: end function P.Init() initializes the data structure P.Insert(r) inserts elements r into 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 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. ExtractMax() 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

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions