Question: Given an array A = < 7 , 6 , 5 , 4 , 3 , 2 , 1 > , apply the bottom -

Given an array A =<7,6,5,4,3,2,1>, apply the bottom-up heap construction algorithm buildMinHeap(A,7) to transform it into a min-heap. Please show the updated array after each swap made during the downHeap procedure.
Follow the pseudocode provided from M6 slides:
buildMinHeap(A, n)
for i =(n/2-1) down to 0
downHeap(A, i)
downHeap(A, i)
smallest = index of the smallest element among
A[i] and its two children
if smallest != i
swap A[i] with A[smallest]
downHeap(A, smallest)

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!