Apex › Storage & databases

Pairing heap — the practical mergeable heap

A heap that is trivial to implement yet fast enough for Dijkstra and Prim (it's in Boost). Unlike an array-based binary heap it merges two heaps in O(1) and supports cheap decrease-key. It's one multi-way tree built almost entirely from "meld"; the only real work is delete-min, which two-pass merges the root's orphaned children. Insert keys and delete the min to watch the tree meld and recombine.

More in Storage & databases