Question: Pleaser justify your answers Problem (100 points) Design Heapsort Using a Min-Heap The objective of this exercise is to use a Min-Heap to implement Heapsort
Problem (100 points) Design Heapsort Using a Min-Heap The objective of this exercise is to use a Min-Heap to implement Heapsort to sort an array A. a) (2 points) Define what a min-heap is. b) (3 points) Consider the array A . Draw this as a heap and explain whether it is a min-heap or not. You may draw by hand the resulting heap, take a picture of your drawing, and insert it in this file. c) (10 points) The following is the Max-Heapify (A,i) procedure. MAX-HEAPIFY (A, i) 1 1 LEFT(i) 2 r-RIGHT(i) 3 ifl A[i] 4 5 else largesti 6 if r A.heap-size and Ar]> Allargest) 7 largest 8 if largest 9 exchange Ali] with Allargest] 10 MAX-HEAPIFY (A, largest) largest l Rewrite Max-Heapify(A.) into Min-Heapify(A,I) to help building a min-heap. d) (5 points) Execute your procedure Min Heapify(AI) to the array A=. Provide what the array A becomes after the execution of Min-Heapify resulting heap. You must provide the representation as an array and a heap. You may draw by hand the resulting heap, take a picture of your drawing, and insert it in this file. e) (10 points) Analyze the time complexity of your Min-Heapify(A.i) procedure
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
