Question: Write a program to implement MaxHeap (build) and then use Heap sort to sort them in C++ pseudocode attached: 1. Find L=21,R=L+1MAXHeAPIFY(A,i,n) 2. If Both

Write a program to implement MaxHeap (build) and then use Heap sort to sort them in C++
pseudocode attached:
Write a program to implement MaxHeap (build) and then use Heap sort
to sort them in C++ pseudocode attached: 1. Find L=21,R=L+1MAXHeAPIFY(A,i,n) 2. If

1. Find L=21,R=L+1MAXHeAPIFY(A,i,n) 2. If Both L and R exists, then lLEFT(i) compare A[L] and A[R] and find rRIGHT(i) the largest of the two if ln and A[l]>A[i] 3. Now check if A[ largest] >A[i] then largest l then swap A[i] with A[ largest] else largest i and then if rn and A[r]>A[ largest ] i= largest and use Recursion to then largest r MaxHeapify(i) if largest =i then exchange A[i]A[ largest ] MAX-HEAPIFY (A, largest, n) HEAPSORT(A,n) BUILD-MAX-HEAP (A,n) for in downto 2 do exchange A[1]A[i] MAXHEAPIFY(A,1,i1)

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!