A Lazy Root List
A Fibonacci heap is a collection of heap-ordered trees whose roots sit in a circular doubly linked list, with one pointer to the root holding the minimum key. Unlike a binomial heap, the trees carry no shape invariant between operations: any number of trees of any degree may coexist.
The design principle is deferral. Insert, meld, and decrease-key perform the least work that leaves the heap correct — a pointer splice — and never restructure. The accumulated disorder is cleaned up by extract-min, the one operation that must inspect the roots anyway. Every bound in the structure is amortized; individual operations can be much more expensive than their stated cost.
The Node Record
Every node carries the fields the operations need, and the record is where the structure's memory cost comes from.
struct Node {
key_t key;
Node *parent;
Node *child; // any one child; the rest via the ring
Node *left, *right; // circular doubly linked sibling ring
int degree; // number of children
bool mark; // has lost a child since it became one
};Children of a node form their own circular ring, so splicing a subtree in or out is a constant-time pointer update with no array to shift. The circularity is what makes meld a ring concatenation rather than a merge. Six fields is roughly 48 bytes of overhead per element on a 64-bit machine, against zero for an array-backed heap.
Insert And Meld
Insertion creates a one-node tree and splices it into the root ring. Melding concatenates two rings. Neither compares more than once or restructures anything.
void insert(Heap *h, Node *x) {
splice_into_ring(h->min, x); // O(1) pointer work
if (!h->min || x->key < h->min->key) h->min = x;
h->n++;
}
Heap *meld(Heap *a, Heap *b) {
concat_rings(a->min, b->min);
a->min = (a->min->key <= b->min->key) ? a->min : b->min;
return a;
}Both are O(1) worst-case, not merely amortized, and neither looks at any node but the two minimum pointers. A heap built by n insertions is a root ring of n singletons, which is a perfectly valid Fibonacci heap — the binomial heap would have spent O(log n) per insert keeping one tree per degree. The disorder is real, and it is left for extract-min to pay off.
Extract-Min
The minimum root is removed and its children are promoted, which is legal because each child subtree is already heap-ordered. Only then is the accumulated disorder paid for.
Node *extract_min(Heap *h) {
Node *z = h->min;
for (Node *c = first_child(z); c; c = next_child(z, c)) {
c->parent = NULL;
splice_into_ring(h->min, c); // promote to the root ring
}
remove_from_ring(z);
h->n--;
if (ring_empty(h)) { h->min = NULL; return z; }
consolidate(h); // the expensive half
return z;
}Promotion is O(degree), bounded by 1.44 log₂ n, and removing the root itself is a constant-time ring splice. Everything costly is in consolidate, which is the only operation in the structure that restructures anything — and it runs once per extraction rather than once per update.
Consolidation
Consolidation reduces the root ring to at most one tree per degree, using an array indexed by degree to find collisions.
void consolidate(Heap *h) {
Node *by_degree[MAX_DEGREE] = {0}; // 1.44 log2 n entries
for (Node *w : snapshot_of_root_ring(h)) {
Node *x = w;
int d = x->degree;
while (by_degree[d]) { // collision at this degree
Node *y = by_degree[d];
if (y->key < x->key) swap(&x, &y); // x keeps the smaller key
link(y, x); // y becomes a child of x
by_degree[d] = NULL;
d++; // x's degree just rose
}
by_degree[d] = x;
}
rebuild_ring_and_min(h, by_degree);
}The snapshot matters: linking rewrites the ring while the loop walks it, so iterating the live ring would skip or revisit roots. Each link removes one tree, so the total work is proportional to the number of roots consumed — which the potential function has already paid for, one unit deposited by each insert that created a root.
Decrease-Key By Cutting
Lowering a key can break heap order on exactly one edge: the one to the node's parent. The repair is to cut that edge and make the node a root.
void cut(Heap *h, Node *x, Node *y) { // x is a child of y
remove_from_child_list(y, x);
y->degree--;
splice_into_ring(h->min, x);
x->parent = NULL;
x->mark = false; // a root is never marked
}
void decrease_key(Heap *h, Node *x, key_t k) {
x->key = k;
Node *y = x->parent;
if (y && x->key < y->key) { cut(h, x, y); cascading_cut(h, y); }
if (x->key < h->min->key) h->min = x;
}The cut restores no shape invariant — the former parent simply loses a child and its degree drops below what its subtree size would justify. That is the whole trade: a binary heap restores its shape immediately and pays O(log n) per decrease-key, while this pays O(1) and leaves the mess for consolidation.
Cascading Cuts
Unlimited cutting would strip a high-degree node until its degree no longer certifies any subtree size, breaking the bound extract-min relies on. One mark bit per node limits the damage to two lost children.
void cascading_cut(Heap *h, Node *y) {
Node *z = y->parent;
if (!z) return; // a root: nothing to do
if (!y->mark) { y->mark = true; return; } // first loss: mark it
cut(h, y, z); // second loss: cut y loose too
cascading_cut(h, z); // and charge the loss to z
}The recursion walks up until it reaches an unmarked node, which it marks, so a cut of c levels clears c − 1 marks. That is what makes the cascade amortize to O(1) despite costing Θ(c) when it happens, and it is why the mark discipline has to be exactly right for the bounds to hold.
The Degree Bound
The mark bit buys an invariant: a node keeps at least all but two of the children it had when they were linked. That is enough to force subtree sizes exponential in the degree.
// children of x, numbered in the order they were linked
child i had degree >= i - 1 when linked, and has lost <= 1 since
=> degree >= i - 2 now
s(k) = minimum subtree size under a node of degree k
s(0) = 1, s(1) = 2, s(k) = 2 + sum over i in [2, k-1] of s(i - 2)
solving: s(k) = F(k + 2) >= phi^k
=> k <= log_phi(n) ~ 1.44 * log2(n)The Fibonacci numbers in that solution are where the structure gets its name, and phi is the golden ratio. The bound is what lets consolidation size its degree array as a fixed small array rather than a growable one, and what caps the root ring at O(log n) entries once consolidation finishes.
The Potential Function
The amortized bounds come from one potential: Φ = t + 2m, counting trees in the root ring and marked nodes. Each operation's amortized cost is its actual cost plus the change in Φ.
insert : t += 1 actual O(1) => O(1)
meld : t, m unchanged actual O(1) => O(1)
extract-min : t -> O(log n) actual O(t) => O(log n)
the released potential pays for the linking
cascading cut of c levels:
actual Theta(c)
t += c, m -= (c - 1)
dPhi = c - 2(c - 1) = 2 - c
total = Theta(c) + 2 - c = O(1)The factor of two on marks is chosen precisely so the −2(c−1) cancels the Θ(c) work. A mark is a prepaid cut: the operation that sets it deposits the potential the eventual cut will spend.
Amortized Bounds
The resulting bounds are O(1) amortized for insert, find-min, meld, and decrease-key, and O(log n) amortized for extract-min and delete. Insert, find-min, and meld are also O(1) in the worst case; decrease-key and extract-min are not.
A single decrease-key can cascade through Θ(log n) levels, and a single extract-min after n insertions consolidates Θ(n) roots. Systems with per-operation latency budgets cannot use these bounds directly. Later designs — strict Fibonacci heaps and Brodal queues — recover the same bounds in the worst case, at the cost of substantially more bookkeeping.
Graph Algorithm Bounds
Dijkstra's algorithm performs n extract-min operations and up to m decrease-key operations. With a binary heap both cost O(log n), giving O(m log n). With a Fibonacci heap the decrease-keys become O(1) amortized and the total falls to O(m + n log n), which is asymptotically better on dense graphs where m approaches n².
Fredman and Tarjan introduced the structure for exactly this purpose in 1984, and applied it to Prim's minimum spanning tree algorithm and to their own O(m β(m, n)) MST algorithm. The bound is still the standard statement of Dijkstra's complexity in the literature, which means the structure's main footprint is in the analysis of algorithms rather than in their implementations.
Constant Factors
A Fibonacci heap node stores a key, parent, child, and two sibling pointers, a degree, and a mark bit — roughly 48 bytes of overhead per element on a 64-bit machine, against zero for an array-backed heap. Every operation dereferences several of those pointers, and the nodes are wherever the allocator put them.
Consolidation walks a root list that may hold thousands of scattered nodes in the same pass. The result is that measured running times often exceed those of a four-ary heap on the same workload despite the better bounds, since the O(1) decrease-key hides a constant several times the cost of a cached array swap. The Boost Graph Library changed the default queue for dijkstra_shortest_paths to a four-ary d_ary_heap_indirect after measuring it roughly 23% faster than the relaxed-heap alternative on its Dijkstra benchmark.
Engineering Trade-offs
Choose a Fibonacci heap when decrease-key dominates the operation mix, the graph or workload is dense enough that the asymptotic gap is real, and the amortized bound is acceptable — batch computations rather than latency-bound services. The O(1) meld also matters when many queues are combined.
Otherwise the costs dominate: six fields per node, one allocation per element, poor locality, and an implementation long enough that correctness depends on the mark discipline being exactly right. A pairing heap gives most of the practical benefit with a fraction of the code, and a d-ary binary heap with lazy deletion is usually faster still on sparse graphs.
Applications
The sources reviewed for this chapter do not identify a prominent production system running a Fibonacci heap on a hot path. Where it appears in shipped software it is an option rather than a default: Boost.Heap provides boost::heap::fibonacci_heap with mutable handles, LEDA offers one among its priority queue implementations, and the GNU C++ policy-based data structures include thin_heap_tag — Tarjan's thin heap, which reproduces the bounds with a simpler node record.
That absence is itself the finding. The asymptotic advantage is real and the constant factors usually cancel it, so implementations that need Dijkstra at scale reach for a four-ary binary heap or a pairing heap instead. The structure's lasting contribution is the analysis: the potential-function argument here is the template for amortized reasoning about lazy structures generally.
Summary
A Fibonacci heap keeps a root list of heap-ordered trees and defers all restructuring to extract-min. Insert, meld, and decrease-key are pointer splices; consolidation rebuilds one tree per degree; and cascading cuts, driven by one mark bit per node, keep subtree sizes exponential in degree so that the maximum degree stays below 1.44 log₂ n.
Insert, find-min, meld, and decrease-key are O(1) amortized; extract-min and delete are O(log n) amortized. Nothing is guaranteed per operation, and the per-node overhead is roughly 48 bytes with pointer-chasing access throughout. The structure buys an asymptotic improvement in graph algorithms that its constants often prevent from appearing in a measurement.