Question: Please consider question 7 to answer question 8 Given an array A[1..7]=17,23,12,32,24,15,9, run Build-Max-Heap (A,7) to convert A into a max-heap. BUILD-MAX-HEAP (A,n) 1 for

Please consider question 7 to answer question 8  Please consider question 7 to answer question 8 Given an array
A[1..7]=17,23,12,32,24,15,9, run Build-Max-Heap (A,7) to convert A into a max-heap. BUILD-MAX-HEAP (A,n)

Given an array A[1..7]=17,23,12,32,24,15,9, run Build-Max-Heap (A,7) to convert A into a max-heap. BUILD-MAX-HEAP (A,n) 1 for i=n/2 downto 1 2MaXHeAPIFY(A,i,n) MAX-HEAPIFY (A,i,n) l=LEFT(i) r=RIGHT(i) if ln and A[l]>A[i] largest =l else largest =i if rn and A[r]>A[ largest ] largest =r if largest =i exchange A[i] with A [largest] MX-HEAPIFY (A, largest, n) (1) What will be the resultant array A after running Build-Max-Heap (A,7) on the given array A. Please write your answer as a sequence of numbers separated by", ". For example: 1, 2, 3, 4, 5, 6, 7 (2) How many key comparisons were made by Build-Max-Heap (A,7) in total? (2) How many key comparisons were made by Build-Max-Heap (A,7) in total? A) Question 8 (6 points) Given an array A[1.7]=17,23,12,32,24,15,9, run Heapsort (A,7) to sort the array into non-decreasing order. You've already obtained the resultant array after the first line of Heapsort in the previous question. Now please show how the rest of the Heapsort algorithm is performed by listing the updated array or drawing the corresponding binary tree after each iteration of the for loop of Heapsort

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!