Question: 1. Consider an array of size eight with the numbers in the following order 40, 20, 80, 60, 30, 10, 70, 50. (a) What is

1. Consider an array of size eight with the numbers in the following order 40, 20, 80, 60, 30, 10, 70, 50.

(a) What is the array after heap creation? Make sure to form the heap bottom up as done in class. How many comparisons does the algorithm use?

(b) Show the array after each element sifts down during the remainder of heapsort, and state how many comparisons each sift takes. What is the total number of comparisons for the remainder of heapsort (i.e., the sum of the comparisons for all of the sifts)?

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!