Pairing heap

A pairing heap is a type of heap data structure with relatively simple implementation and excellent practical amortized performance, introduced by Michael Fredman, Robert Sedgewick, Daniel Sleator, and Robert Tarjan in 1986. Pairing heaps are heap-ordered multiway tree structures, and can be considered simplified Fibonacci heaps. They are considered a "robust choice" for implementing such algorithms as Prim's MST algorithm, and support the following operations (assuming a min-heap): The analysis of pairing heaps' time complexity was initially inspired by that of splay trees. The amortized time per delete-min is O(log n), and the operations find-min, meld, and insert run in O(1)amortized time.
 * find-min: simply return the top element of the heap.
 * meld: compare the two root elements, the smaller remains the root of the result, the larger element and its subtree is appended as a child of this root.
 * insert: create a new heap for the inserted element and meld into the original heap.
 * decrease-key (optional): remove the subtree rooted at the key to be decreased, replace the key with a smaller key, then meld the result back into the heap.
 * delete-min: remove the root and do repeated melds of its subtrees until one tree remains. Various merging strategies are employed.

When a decrease-key operation is added as well, determining the precise asymptotic running time of pairing heaps has turned out to be difficult. Initially, the time complexity of this operation was conjectured on empirical grounds to be O(1),  but Fredman proved that the amortized time per decrease-key is at least  for some sequences of operations. Using a different amortization argument, Pettie then proved that insert, meld, and decrease-key all run in  amortized time, which is . Elmasry later introduced elaborations of pairing heaps for which decrease-key runs in  amortized time and other operations have optimal amortized bounds, but no tight  bound is known for the original data structure.

Although this is worse than other priority queue algorithms such as Fibonacci heaps, which perform decrease-key in  amortized time, the performance in practice is excellent. Stasko and Vitter,  Moret and Shapiro, and Larkin, Sen, and Tarjan conducted experiments on pairing heaps and other heap data structures. They concluded that pairing heaps are often faster in practice than array-based binary heaps and d-ary heaps, and almost always faster in practice than other pointer-based heaps, including data structures like Fibonacci heaps that are theoretically more efficient.