Question: Here is the heapsort algorithm void Heapsort (int [] heap, int N) // Organize the array in a heap (buildheap) for (k = N/2; k

 Here is the heapsort algorithm void Heapsort (int [] heap, int

Here is the heapsort algorithm void Heapsort (int [] heap, int N) // Organize the array in a heap (buildheap) for (k = N/2; k > = 1; k-) { downheap (heap, N, k); // remove each node in turn While (N > 1) int tempo = heap [1]; heap [1] = heap [n]; heap [N] = tempo; downheap (heap,N, 1); a) Give the algorithm of the method downheap in the case of a max-heap b) Sort the arrays below using this heapsort. Give the State of the table after each call to the function downheap. 4 7 12 32 21 2

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!