Question: 1. For the max heap (stored as an array) depicted below, which best describes what happens when 87 is added. 87 is added as a

1. For the max heap (stored as an array) depicted below, which best describes what happens when 87 is added.

1. For the max heap (stored as an array) depicted below, which

87 is added as a child of 17 and then filters up

None of the others

87 replaces 17, which has to be readded

2.What is the worst-case runtime complexity of merging two binary heaps (stored as arrays)? Each heap has N elements.

O(1) link two heaps

O(n log n) Inserting each element of one array into the other.

None of the others

O(log n) Recursively merge heaps

3.

For the max heap (stored as an array) depicted below, what best describes what happens when the maximum is deleted?

best describes what happens when 87 is added. 87 is added as

91 is removed replaced with 15 (which has to filter down)

91 is removed and its children are merged

91 is replaced with the bigger of its children (and the process repeats at the deleted child)

None of the others

4.For the following code on a max heap (stored as an array), what is the purpose of the code? List any errors. For n elements, the heap is stored at locations A[0] to A[n-1].

boolean mystery ( ) { for (int k=0; k

It performs no useful function.

It inserts an element into a max heap.

It checks to see if the heap is correctly formed. However, it may miss checking the kids of some nodes.

It builds a max heap.

91 52 17 15 34 26 91 52 17 15 34 26

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!