Question: Question 4: 1. Say that a pointer p points to an element in the middle of a heap. Give an O (log n ) time

Question 4: 1. Say that a pointer p points to an element in the middle of a heap. Give an O (log n ) time algorithm to remove this element from the heap. Hint: Its very similar to regular delete. 2. Say that we want to maintain two Heaps one with the minimum at the top (and the children no smaller than the parent) and one with the maximum on the top (and the children no larger than the parent). Thus the operations we want to maintain are Delete M ax ( H ), Delete M in ( H ) and Insert ( H, x ). Use two heaps with pointers between two copies of the same elements so that the above operations could be done in O (log n ) each. Note that Delete M ax , also deletes this item from the M in Heap . Further, this element can be located in the middle of the M in Heap . Hint: Use part 1 that explains how to delete a vertex from the middle of a Heap.

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!