Mergeable heap

In computer science, a mergeable heap (also called a meldable heap) is an abstract data type, which is a heap supporting a merge operation.

Definition
A mergeable heap supports the usual heap operations:
 * , create an empty heap.
 * , insert an element  into the heap.
 * , return the minimum element, or  if no such element exists.
 * , extract and return the minimum element, or  if no such element exists.

And one more that distinguishes it:
 * , combine the elements of  and   into a single heap.

Trivial implementation
It is straightforward to implement a mergeable heap given a simple heap:



This can however be wasteful as each  and   typically have to maintain the heap property.

More efficient implementations
Examples of mergeable heap data structures include:


 * Binomial heap
 * Fibonacci heap
 * Leftist tree
 * Pairing heap
 * Skew heap

A more complete list with performance comparisons can be found at.

In most mergeable heap structures, merging is the fundamental operation on which others are based. Insertion is implemented by merging a new single-element heap with the existing heap. Deletion is implemented by merging the children of the deleted node.