Question: PLEASE ANSWER THE QUESTION BEING ASKED. What is the runtime of HEAPSORT (on this file) on an array A of length n that is already

 PLEASE ANSWER THE QUESTION BEING ASKED. What is the runtime of

PLEASE ANSWER THE QUESTION BEING ASKED.

HEAPSORT (on this file) on an array A of length n that

What is the runtime of HEAPSORT (on this file) on an array A of length n that is already sorted in increasing order? What about decreasing order? Explain your answer in sufficient details. HEAP-SORT(A) // Input: A: an (unsorted) array // Output: A modified to be sorted from smallest to largest // Running Time: O(n log n) where n = length[A] 1 BUILD-MAX-HEAP(A) 2 for i = length[A] downto 2 3 exchange A[1] and Ald 4 heap-size[A] - heap-size[A] - 1 5 MAX-HEAPIFY(A, 1)

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!