Variations of Pairing Heaps

Data Structure AlgorithmsAnalysis of AlgorithmsAlgorithms

A pairing heap can be either an empty heap, or a pairing tree containing of a root element and a possibly empty list of pairing trees.

The heap ordering property needs that parent of any node is no greater than the node itself.

The following description considers a purely functional heap that does not support the decrease-key operation.

type PairingTree[Element] = Heap(element: Element, subheaps: List[PairingTree[Element]])

type PairingHeap[Element] = Empty | PairingTree[Element]

Pairing heaps exist in two varieties--min pairing heaps and max pairing heaps. Min pairing heaps are implemented when we wish to represent a min priority queue, and max pairing heaps are implemented for max priority queues. As per our discussion of heaps and leftist trees in the text, we explicitly discuss max pairing heaps here. Min pairing heaps can be analogous.

A max pairing heap is defined as simply a max tree.

Four max pairing heaps are shown below. Notice that a pairing heap does not require being a binary tree.

Published on 02-Jan-2020 11:30:53