Question: For HEAPSORT codes belowHeapsort (A){Build-MAX-Heap(A);for(i = A.length downto2){Swap(A[1], A[i]);A.heap_size= A.heap_size -1;MAX-Heapify(A, 1);}} What is the number of required swap operations when heapsort the array A

For HEAPSORT codes belowHeapsort

(A){Build-MAX-Heap(A);for(i = A.length downto2){Swap(A[1], A[i]);A.heap_size= A.heap_size -1;MAX-Heapify(A, 1);}}

What is the number of required swap operations when heapsort the array A = {5, 13, 2, 25, 7, 17, 20, 8, 4}? Explain your reason.

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

(c) Does the asymptotic upper bound of Heapsort increase from O(nlgn) to O(n2)? Why?

 (Hint: compare the number of swap operations before and after the change for the worst case).

Step by Step Solution

3.30 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a To find the number of required swap operations when heapsorting the array A 5 13 2 25 7 17 20 8 4 ... View full answer

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 Algorithms Questions!