Question: Heaps and Heapsort (25 points) 2.1 Is the sequence 23, 17,14,6, 13, 10, 1,5,7,12> a max-heap? Why or why not? 2.2 Illustrate the operation of

Heaps and Heapsort (25 points) 2.1 Is the sequence 23, 17,14,6, 13, 10, 1,5,7,12> a max-heap? Why or why not? 2.2 Illustrate the operation of MAX-HEAP!Fy(A; 3) on the array A =, 2 using the binary trees as we did in class. 2.3 Illustrate the operation of BUILD-MAX-HEAP(A) on the array A =, using the binary trees as we did in class 2.4 You are given a list of numbers for which you need to construct a min-heap. How would you use an algorithm for constructing a max-heap to construct a min-heap? Explain in your own words. 2.5 Argue the correctness of Heapsort using the following loop invariant: At the start of each iteration of the for loop, the subarray A1,,i] is a max-heap containing the i smallest elements of A[1,... ,n], and the subarray Ali + 1,... ,n] contains the n-i largest elements of A[1,... ,n]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
