Removing the Min Element from Interval Heaps

Data Structure AlgorithmsAnalysis of AlgorithmsAlgorithms

  • In an interval heap, the smallest element is the element on the left hand side of the root node. This element is eliminated and returned.
  • For filling the vacancy created on the left hand side of the root node, an element from the last node is eliminated and again inserted into the root node.
  • This element is next compared successively with all the left hand elements of the descending nodes and the process terminates when all the conditions for an interval heap are met.
  • In case if the left hand side element in the node becomes higher than the right side element at any stage, the two elements are exchanged and then further comparisons are performed.
  • At last, the root node will again contain the smallest element on the left hand side.

This procedure can also be explained in following ways -

The removal of the minimum element is handled as several ways -

  • When the interval heap is vacant, the removeMin operation fails.
  • When the interval heap has only one element, this element should be returned. We leave behind an interval heap without any element.
  • When there is more than one element, the left end point of the root should be returned. This point is eliminated from the root.
  • If the root indicates the last node of the interval heap, nothing more is to be done.
  • When the last node is not the root node, we eliminate the left point p from the last node. If this causes the last node to become vacant, the last node is no longer part of the heap.
  • The point p eliminated from the last node is reinserted into the embedded min heap by beginning at the root.
  • As we move down, it may be necessary to exchange the current p with the right end point r of the node being examined to ensure that p ≤r. The reinsertion is performed implementing the same strategy as used to reinsert into an ordinary heap.
Published on 02-Jan-2020 12:25:02