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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4ee9f751d5_90266f4ee9edf475.jpg)
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
Get step-by-step solutions from verified subject matter experts
