Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions