Question: Suppose, we have the current data split between Hmax and Hmin and we wish to insert an element ???? into the data structure, describe the
Suppose, we have the current data split between Hmax and Hmin and we wish to insert an element ???? into the data structure, describe the algorithm you will use to insert. Your algorithm must decide which of the two heaps will ???? be inserted into and how to maintain the size balance condition.
Describe the algorithm below and the overall complexity of an insert operation. This part will not be graded
First, the size of each heap (h-max and h-min) will be checked. If the sizes of the heaps are equal, the element will be inserted into either heap. If one heap is larger than the other, the heap will be inserted into the small heap.
(B) Design algorithm for finding the median.
Implement an algorithm for finding the median given the heaps Hmin and Hmax. What is its complexity?
Step by Step Solution
3.37 Rating (163 Votes )
There are 3 Steps involved in it
To maintain a balanced structure when inserting an element into two heaps Hmax and Hmin you can follow these steps Check Heap Sizes Determine the size... View full answer
Get step-by-step solutions from verified subject matter experts
