Question: a . Suppose A [ 1 n ] and B [ 1 n ] are heaps storing key values. Does C [ 1 n ]

a. Suppose A[1 n] and B[1 n] are heaps storing key values. Does
C[1 n] where C[i]= A[i]+ B[i] for i =1,..., n represent a heap? Why or why not?
b. Again, let A[1 n] store the keys of a heap. Write a pseudocode for the
method replaceKey(i, k): Replace the key at A[i] with k.
You must incorporate the pseudocode for BubbleUp and BubbleDown in your algorithm. Briefly explain why your implementaon is correct and why its running time is O(log n).

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!