Question: Heapsort Max Heap You are given the array with 7 elements: ( 3 , 5 , 1 , 2 , 6 , 7 ,
Heapsort
Max Heap
You are given the array with elements:
Use heapsort algorithm to arrange the elements of this array in increasing order. For this question do construct max heap.
At the end of each iteration of the algorithm, and when the last element is pushed out of the tree into a sorted list after "pruning" the tree enter the state of the remaining tree as a list. Do not separate elements of the list, enter it as a sequence of numbers: eg if the current remaining tree is enter
state of the tree after st iteration:
state of the tree after nd iteration:
state of the tree after rd iteration:
state of the tree after th iteration:
state of the tree after th iteration:
state of the tree after th iteration:
Note: To construct sorted list in the ascending order, after the end of each iteration, the "pruned" element is added to the front of the sorted list ie from the left which will ensure the sorted list is in increasing order. This is not required to be entered in this question's solution, but you can use it to construct the sorted list from your given input list to confirm your result.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
