Course Solutions Uncategorized (Solved) : Heapsort Codes Heapsort Build Max Heap Length Downto 2 Swap 1 Heapsize Heapsize 1 Max Heap Q31188603 . . . .

(Solved) : Heapsort Codes Heapsort Build Max Heap Length Downto 2 Swap 1 Heapsize Heapsize 1 Max Heap Q31188603 . . . .

 

For HEAPSORT codes below

Heapsort(A)

{

Build-MAX-Heap(A);

for (i = A.length downto 2)

{

Swap(A[1], A[i]);

A.heap_size= A.heap_size – 1;

MAX-Heapify(A, 1);

}

}

(a) What is the number of required swap operations when heapsortthe array A = {5, 13, 2, 25, 7, 17, 20, 8, 4}? Explain yourreason.

(b) If we replace MAX-Heapify(A, 1) with Build-MAX-Heap(A), whatis the number of required swap operations when heapsort the arrayA? Explain your reason.

(c) (Does the asymptotic upper bound of Heapsort increase fromO(nlgn) to O( 2 )? Why? (Hint: compare the number ofswap operations before and after the change for the worstcase).

Expert Answer


An answer will be send to you shortly. .

OR

PayPal Gateway not configured

OR

PayPal Gateway not configured

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Solved) : Anyone Know Task 21 22 23 Please Provide Code Q31742272 . . . .(Solved) : Anyone Know Task 21 22 23 Please Provide Code Q31742272 . . . .

Anyone know how to do task 2.1, 2.2 and 2.3? Please providethe code<br/><img src="https://media.cheggcdn.com/media%2F87c%2F87c5310d-9e94-4cfc-a32b-e52d8cd92488%2Fimage.png" alt="media%2F87c%2F87c5310d-9e94-4cfc-a32b-e5"/><img src="https://media.cheggcdn.com/media%2Fc5b%2Fc5bc40d9-954c-4e3a-8224-8351ed27f9a3%2Fimage.png" alt="media%2Fc5b%2Fc5bc40d9-954c-4e3a-8224-83"/>Show transcribed image text Expert Answer Answer to Anyone know how to