Overview

Fibonacci heaps are a sophisticated implementation of mergeable heaps that achieve excellent amortized time bounds by deferring consolidation work. They support INSERT, UNION, and DECREASE-KEY in O(1) amortized time, and EXTRACT-MIN and DELETE in O(lg n) amortized time. These bounds make Fibonacci heaps theoretically optimal for algorithms like Dijkstra's shortest paths and Prim's minimum spanning tree, where DECREASE-KEY is called frequently.

Key Concepts

Algorithms and Techniques

FIB-HEAP-INSERT(H, x)

Initializes x (degree 0, unmarked, no parent/child) and adds it to the root list. Updates H.min if x.key < H.min.key. Increments H.n. Amortized cost: O(1) (potential increases by 1).

FIB-HEAP-UNION(H1, H2)

Concatenates the root lists of H1 and H2, updates the min pointer, and sets H.n = H1.n + H2.n. Amortized cost: O(1) (potential change is 0).

FIB-HEAP-EXTRACT-MIN(H)

The most complex operation:

  1. Add all children of the minimum node z to the root list.

  2. Remove z from the root list.

  3. CONSOLIDATE(H): Repeatedly link roots with the same degree until all roots have distinct degrees. Uses an auxiliary array A[0..D(H.n)] indexed by degree. For each root w, if another root y in A has the same degree, link the one with the larger key under the one with the smaller key, incrementing the winner's degree.

  4. Rebuild the root list from array A and find the new minimum.