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):
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.
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.
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 (lazy, consolidate) 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.