Suppose, we have the current data split between Hmax and Hmin and we wish to insert an
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 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?
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young