Question: 6. (15 points) Building a heap using insertion The procedure BuildHeap can also be implemented by repeatedly using Heaplnsert to insert the ele- ments into

 6. (15 points) Building a heap using insertion The procedure BuildHeap

6. (15 points) Building a heap using insertion The procedure BuildHeap can also be implemented by repeatedly using Heaplnsert to insert the ele- ments into the heap. Consider the following implementation: BuildHeap2(A) heapsize(A)1; for (i 2 to length (A)) HeapInsert (A, Ai]); a. (8 points) illustrate the operation of BuildHeap2 on array A = [14 15 10 5 6 16 11 3 12 201 . Show the content of the heap and the array A after each HeapInsert. Compare the result with the result obtained above in 4c. Do the two procedures create the same heap at the end? b. (5 points) What is the worst-case time complexity of BuildHeap2? Briefly justify your answer c. (2 points) How does the running time of the two procedures compare

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!