Question: Consider the following array. A = [ 7 , 8 , 2 , 1 , 4 , 6 , 3 , 5 ] 1 .

Consider the following array.
A =[7,8,2,1,4,6,3,5]
1. Show the array as a heap.
2. Preform the Build-Max-Heap algorithm on A. Show the heap after each swap you make.
(hint: you should draw the heap 3 times not counting the initial heap you made in question 1)
3. Preform the HeapSort algorithm on A. Show the heap after each iteration of the for loop.
(hint: you should draw the heap 7 times not including the empty heap when the array is fully sorted
or the initial max heap you created in question 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 Programming Questions!