Skip to content

Binomial Heap — Mathematical Foundations and Complexity Theory

The binomial heap, introduced by Jean Vuillemin in 1978 ("A data structure for manipulating priority queues", Communications of the ACM 21(4)), occupies a unique place in the lattice of priority-queue data structures. It is the first mergeable heap to achieve O(log n) worst-case complexity for all three core operations — insert, extract-min, and meld — without amortisation, without randomisation, and without auxiliary data structures. Its elegance lies in the deep correspondence between its forest structure and the binary representation of n: a binomial heap of size n is, quite literally, the binary numeral n made physical, with each 1-bit at position k materialised as a binomial tree B_k. This professional treatment formalises that correspondence, proves the structural invariants by induction, derives the amortised bound on insert via the potential method, and surveys the modern descendants — Brodal–Okasaki purely functional queues, skew binomial heaps, and the still-open question of deterministic O(1) worst-case decrease-key.

Table of Contents

  1. Formal Definition — Binomial Tree B_k Recursively
  2. Structural Properties — Nodes at Depth i = C(k,i)
  3. Number of Trees in a Heap of Size n = popcount(n)
  4. Loop Invariants for _union
  5. Amortised O(1) Insert via Potential Function Φ = #trees
  6. Worst-Case O(log n) for All Other Ops
  7. Comparison with Fibonacci Heap — Why Lazy Won
  8. Purely Functional Variants — Brodal–Okasaki
  9. Skew Binomial Heaps — O(1) Worst-Case Insert
  10. Open Problems and Variants
  11. Summary

1. Formal Definition

1.1 Recursive construction

The binomial tree B_k is defined inductively on k ∈ ℕ:

  • Base case. B_0 is the single-node tree.
  • Inductive step. B_{k+1} is obtained by taking two copies of B_k, designating the root of one as the new root, and making the root of the other its leftmost child.
B_0:   •

B_1:   •           = link(B_0, B_0)
       |

B_2:   •           = link(B_1, B_1)
      / \
     •   •
     |

B_3:   •           = link(B_2, B_2)
     / | \
    •  •  •
   /|  |
  • •  •
  |

Equivalently, the children of the root of B_k, read left-to-right, are the roots of B_{k-1}, B_{k-2}, …, B_1, B_0 — a fact that follows directly from the link construction.

1.2 Proof that |B_k| = 2^k

Theorem 1. For all k ≥ 0, the number of nodes in B_k equals 2^k.

Proof by induction on k.

  • Base. |B_0| = 1 = 2^0. ✓
  • Step. Assume |B_j| = 2^j for all j ≤ k. By construction, B_{k+1} is the disjoint union of two copies of B_k with one new edge but no new node. Hence |B_{k+1}| = 2 · |B_k| = 2 · 2^k = 2^{k+1}.

By induction, |B_k| = 2^k for all k ≥ 0. ∎

1.3 Height and degree

Theorem 2. B_k has height exactly k, and the root of B_k has degree exactly k.

Proof. Both claims follow by induction on k. For the height: the link operation makes the root of one B_k a child of the other's root, so the deepest leaf descends one further level, giving height k+1. For the degree: linking increases the root's child count by exactly one, from k to k+1. ∎

A binomial heap H is a forest of binomial trees, each obeying the min-heap order (key of every node keys of its children), with the additional uniqueness invariant: no two trees in H have the same order k. The uniqueness invariant is what couples the structure to the binary numeral system.


2. Structural Properties

2.1 Nodes at depth i

Theorem 3. The number of nodes at depth i in B_k equals the binomial coefficient C(k, i) = k! / (i!(k-i)!).

This is the property that gives the data structure its name.

Proof by induction on k.

Let N(k, i) denote the number of nodes at depth i in B_k.

  • Base. B_0 has one node at depth 0 and none elsewhere: N(0, 0) = 1 = C(0, 0), and N(0, i) = 0 = C(0, i) for i > 0. ✓
  • Step. Assume N(k, i) = C(k, i) for all i. We construct B_{k+1} by attaching a copy B'_k of B_k as the leftmost child of the root of another copy B''_k. Then a node at depth i in B_{k+1} is either:
  • a node at depth i in B''_k, contributing N(k, i) nodes; or
  • a node at depth i-1 in the attached B'_k (one level deeper after attachment), contributing N(k, i-1) nodes.

Therefore N(k+1, i) = N(k, i) + N(k, i-1) = C(k, i) + C(k, i-1) = C(k+1, i), by Pascal's identity.

By induction, N(k, i) = C(k, i) for all k, i. ∎

2.2 Consequences

Summing over all depths gives an independent confirmation of Theorem 1:

|B_k| = Σ_{i=0}^{k} C(k, i) = 2^k     (binomial theorem with x = 1)

The maximum degree of any node in B_k is k, attained only at the root. Hence in a binomial heap of size n, the maximum degree of any node is at most ⌊log₂ n⌋.


3. Number of Trees in a Heap of Size n = popcount(n)

3.1 The binary correspondence

Theorem 4. A binomial heap H of size n contains exactly popcount(n) trees, where popcount(n) is the number of 1-bits in the binary representation of n. Moreover, if n = Σ_{k ∈ S} 2^k is the unique binary decomposition with S ⊆ ℕ, then H contains exactly one tree B_k for each k ∈ S.

Proof. Each B_k contains 2^k nodes (Theorem 1). The uniqueness invariant forbids two trees of the same order. Therefore the multiset of orders {k_1, …, k_t} of trees in H is a set, and Σ_{i=1}^{t} 2^{k_i} = n. By uniqueness of binary representation, this set is precisely the index set of the 1-bits of n, and its cardinality is popcount(n). ∎

3.2 Upper bound on the number of trees

Since popcount(n) ≤ ⌊log₂ n⌋ + 1, every binomial heap of size n has at most ⌊log₂ n⌋ + 1 trees, i.e. O(log n). This is the structural bound that powers all logarithmic worst-case operations.

3.3 Concrete example

For n = 13 = 1101₂, the heap contains exactly three trees: B_3 (8 nodes), B_2 (4 nodes), B_0 (1 node). popcount(13) = 3.


4. Loop Invariants for _union

The _union operation merges two binomial heaps into one by walking through their root lists in increasing order of degree, akin to binary addition with carry.

4.1 Pseudocode

function union(H1, H2):
    H ← merge_root_lists(H1, H2)     # interleave by ascending degree
    if H is empty: return H
    prev ← null
    cur  ← H.head
    next ← cur.sibling
    while next ≠ null:
        case A: cur.degree ≠ next.degree
                or (next.sibling ≠ null and next.sibling.degree = cur.degree):
            # no carry — advance
            prev ← cur; cur ← next
        case B: cur.key ≤ next.key:
            # link next under cur
            cur.sibling ← next.sibling
            link(next, cur)
        case C: cur.key > next.key:
            # link cur under next; cur moves forward
            if prev = null: H.head ← next else prev.sibling ← next
            link(cur, next)
            cur ← next
        next ← cur.sibling
    return H

4.2 Invariants

Let the root list be r_1, r_2, …, r_m at any point during the loop, with cur = r_j for some j.

Invariant I1 (strictly increasing degrees to the left). At the start of every iteration, the degrees of r_1, r_2, …, r_{j-1} form a strictly increasing sequence.

Invariant I2 (no future degree decrease). For every i < j and every i' ≥ j, degree(r_i) < degree(r_{i'}) or the carry that produced r_{i'} has yet to propagate — but the carry can only propagate to the right.

Invariant I3 (heap order preserved). Every link step preserves min-heap order locally, hence globally.

Invariant I4 (size preserved). The multiset of stored elements is invariant; only forest structure changes.

4.3 Proof sketch for I1

By induction on the number of iterations.

  • Initialisation. Before the first iteration, j = 1 and r_1, …, r_{j-1} is empty, so I1 holds vacuously.
  • Maintenance. Suppose I1 holds at iteration start. We perform one of cases A, B, C:
  • Case A advances cur. We assert that degree(r_{j}) < degree(r_{j+1}) (else case B or C fires). Combined with I1, this maintains strict increase up to index j.
  • Case B links next under cur (since cur.key ≤ next.key). The new root at position j has degree degree(cur) + 1. The previous left neighbour r_{j-1} had degree < degree(cur) < degree(cur) + 1, so the increasing chain is preserved.
  • Case C is symmetric: cur becomes a child of next, and next takes position j with degree degree(cur) + 1. Same argument.
  • Termination. When next = null, I1 holds for the entire root list, which is exactly the heap invariant.

The loop runs O(log n_1 + log n_2) iterations because each root list has O(log n) elements (Theorem 4), and each iteration either advances cur or merges two roots into one (reducing the list length).


5. Amortised O(1) Insert

5.1 Potential function

Define the potential of a binomial heap H as

Φ(H) = number of trees in H = t(H).

By Theorem 4, Φ(H) = popcount(|H|), and 0 ≤ Φ(H) ≤ ⌊log₂ |H|⌋ + 1.

5.2 Amortised cost of insert

To insert one element x:

  1. Create a new heap H' = {B_0(x)} with Φ(H') = 1.
  2. Meld H ← union(H, H').

The meld walks the root list of H and carries B_0(x) as a B_0 carry bit. Suppose k linking steps occur before the carry settles. The structural change is:

  • k trees of orders 0, 1, …, k-1 are consumed and merged into one new tree of order k.
  • Net change in tree count: Δt = 1 - k (gained one, lost k).

Thus

Δ Φ = Δt = 1 - k.

The actual cost is c_actual = O(k + 1) (k link operations plus constant overhead). The amortised cost is

c_amortised = c_actual + Δ Φ = (k + 1) + (1 - k) = 2 = O(1).

5.3 Aggregate confirmation

Starting from an empty heap, performing n inserts yields a heap of size n. The total number of link operations equals the total number of carries in binary increments from 0 to n, which is n - popcount(n) < n. So the average cost per insert is strictly less than 1 link, giving O(1) amortised. The potential method derives the same conclusion locally.

5.4 Cost of other operations

Operation Actual ΔΦ Amortised
insert O(k + 1) 1 - k O(1)
find-min O(t) = O(log n) 0 O(log n)
meld O(t_1 + t_2) ≤ 0 O(log n)
extract-min O(log n) +(deg − 1) O(log n)
decrease-key O(log n) 0 O(log n)
delete O(log n) O(log n) O(log n)

find-min can be made O(1) worst-case by caching a pointer to the minimum root and updating on every mutator.


6. Worst-Case O(log n) for All Other Ops

6.1 Bounding factors

Every non-insert operation is dominated by one of:

  • the length of the root list (≤ ⌊log₂ n⌋ + 1);
  • the degree of a tree's root (≤ ⌊log₂ n⌋);
  • a constant number of meld traversals.

Each is O(log n). So find-min, meld, extract-min, decrease-key, and delete all have O(log n) worst-case cost — not merely amortised.

6.2 extract-min details

function extract_min(H):
    z ← root of minimum key in root list      # O(log n)
    remove z from root list                    # O(log n)
    H' ← reversed child list of z              # O(deg(z)) = O(log n)
    H ← union(H, H')                           # O(log n)
    return z

The reversal converts the descending-degree child list (B_{k-1}, …, B_0) into the ascending-degree root list expected by union.

6.3 decrease-key details

Standard sift-up along parent pointers; the path length is at most O(log n) since tree depth is bounded by tree order.


7. Comparison with Fibonacci Heap — Why Lazy Won

Fibonacci heaps (Fredman–Tarjan 1987) replace the strict structural invariants of binomial heaps with lazy consolidation: trees are merged only during extract-min, and structural slack is amortised against the marking discipline of decrease-key. The result is a markedly better amortised profile for graph algorithms.

Operation Binomial (W/C) Binomial (Amort.) Fibonacci (Amort.)
insert O(log n) O(1) O(1)
find-min O(1)* O(1)* O(1)
meld O(log n) O(log n) O(1)
extract-min O(log n) O(log n) O(log n)
decrease-key O(log n) O(log n) O(1)
delete O(log n) O(log n) O(log n)

* with cached min pointer.

The O(1) amortised decrease-key is decisive: Dijkstra's algorithm runs in O(E + V log V) with Fibonacci heaps versus O((E + V) log V) with binomial heaps. For dense graphs (E = Θ(V²)), this saves a logarithmic factor.

So why is the binomial heap still studied and used? Three reasons:

  1. Worst-case bounds. Fibonacci heaps are amortised; binomial heaps give per-operation O(log n). Real-time systems prefer the latter.
  2. Constant factors. Fibonacci heaps carry large hidden constants from the cascading-cut and marking machinery. Empirical studies (Cherkassky–Goldberg–Radzik 1996) routinely show binomial heaps outperforming Fibonacci heaps on inputs up to millions of nodes.
  3. Conceptual cleanliness. The binomial structure underpins skew binomial heaps, Brodal–Okasaki queues, and the soft heap; all are descendants of Vuillemin's construction, not Fredman–Tarjan's.

8. Purely Functional Variants — Brodal–Okasaki

In their 1996 paper Optimal Purely Functional Priority Queues (POPL'96), Gerth Brodal and Chris Okasaki present a data structure with the following worst-case bounds in a fully persistent, immutable setting:

Operation Brodal–Okasaki (W/C, persistent)
insert O(1)
find-min O(1)
meld O(1)
extract-min O(log n)

8.1 The "global root" trick

The core idea is the bootstrapping via structural abstraction technique: any priority queue Q with O(log n) extract-min and O(1) meld can be transformed into one with O(1) find-min by storing the minimum separately at a global root. To meld, compare the two global roots; the loser, along with its associated queue, is inserted as an element into the winner's auxiliary queue (a queue of queues). Recursion of this construction is well-founded because each level of nesting halves the work, and Okasaki shows the recursion terminates after O(log* n) levels.

8.2 Persistence via lazy evaluation

The skew binomial heaps used as the underlying queue support O(1) insert and meld in the worst case via amortised analysis converted to worst case using lazy evaluation and Okasaki's implicit recursive slowdown technique. The result is fully persistent: any past version of the queue can be queried or mutated, branching the history into a tree.

8.3 Decrease-key

Brodal–Okasaki does not support decrease-key efficiently in a purely functional model — locating an arbitrary node requires O(n) traversal because there are no parent pointers in immutable structures, and the persistence requirement precludes the usual workaround.


9. Skew Binomial Heaps

Brodal and Okasaki (1996) — and earlier Kaplan and Tarjan (in their work culminating in "Persistent Lists with Catenation via Recursive Slow-Down", STOC 1999) — introduce skew binomial trees to attain O(1) worst-case insert without amortisation.

9.1 Skew binomial trees

A skew binomial tree of rank r is defined by allowing two link operations:

  • Simple link. Two trees of rank r combine into one of rank r + 1 (as in the standard binomial link).
  • Skew link. A new singleton plus two trees of rank r combine into one of rank r + 1, with the singleton placed at the root.

9.2 Skew binary numbers

The structural invariant uses the skew binary number system, in which each digit is 0, 1, or 2, and at most one 2-digit appears, which must be the lowest non-zero digit. In skew binary, incrementing by 1 requires at most one carry:

  • If the lowest non-zero digit is 2, replace it with 0 and increment the next digit.
  • Otherwise simply add 1 to the lowest digit.

In either case the operation is O(1) regardless of the value. Translating back: an insert performs at most one skew link, which is constant work.

9.3 Bounds achieved

Skew binomial heaps deliver:

Operation Skew binomial (W/C)
insert O(1)
find-min O(log n)*
meld O(log n)
extract-min O(log n)

* Reducible to O(1) with a cached min pointer.

This achieves the same O(1) worst-case insert as Fibonacci heaps, but with deterministic bounds and no lazy marking machinery.


10. Open Problems and Variants

10.1 The decrease-key question

The grand open problem of priority-queue theory is:

Is there a data structure supporting insert, meld, and decrease-key in O(1) worst-case time (not amortised), and extract-min in O(log n) worst-case, in the comparison model and without randomisation?

Fibonacci heaps achieve these bounds amortised. Brodal queues (Brodal 1996, "Worst-Case Efficient Priority Queues", SODA'96) achieve them worst-case but with extreme constant factors and intricate machinery. Strict Fibonacci heaps (Brodal–Lagogiannis–Tarjan 2012) provide deterministic worst-case bounds matching Fibonacci heaps amortised, settling much — but not all — of the question. Whether a simple structure with these bounds exists remains open.

10.2 Cache-oblivious binomial heap

Cache-oblivious priority queues (Arge–Bender–Demaine–Holland–Munro 2007 and related) are based on funnel-heaps and bucket structures rather than binomial trees. A cache-oblivious binomial heap that retains the recursive B_k structure but lays it out for optimal block transfers remains an under-explored topic; the natural tension is that the recursive doubling structure is cache-friendly for inserts but not for extract-min, where reversing the child list breaks locality.

10.3 Concurrent binomial heaps

Lock-free meldable priority queues based on binomial heaps (Hunt–Michael–Parthasarathy–Scott 1996, and later) trade some worst-case asymptotic strength for compare-and-swap-based concurrency. The binomial structure's local meld semantics make it more amenable to fine-grained locking than Fibonacci heaps' global consolidation.

10.4 Soft heap and approximate priority queues

Chazelle's soft heap (2000) is not a binomial heap but borrows the binomial linking pattern. By corrupting up to an ε-fraction of keys, it achieves O(1) amortised on all operations except extract-min. The soft heap was the key tool in Chazelle's O(m · α(m, n)) minimum spanning tree algorithm.


11. Summary

The binomial heap is the structural fixed-point of "priority queue isomorphic to a binary numeral":

  • |B_k| = 2^k, height(B_k) = k, nodes at depth i = C(k, i) (Theorems 1–3).
  • A heap of size n is the binary expansion of n (Theorem 4): popcount(n) trees, one per 1-bit.
  • union is binary addition over a strictly-increasing-degree invariant maintained by Section 4.
  • The potential Φ = #trees yields O(1) amortised insert via Section 5; all other operations are O(log n) worst case (Section 6).
  • Fibonacci heaps trade the worst-case bound for O(1) amortised decrease-key (Section 7), but the binomial structure persists as the foundation of all subsequent meldable heaps.
  • Brodal–Okasaki (1996) deliver O(1) worst-case insert/meld/find-min in a fully persistent setting (Section 8), built atop skew binomial heaps (Section 9), themselves a worst-case O(1) insert variant due to Brodal–Okasaki and Kaplan–Tarjan.
  • Open problems remain — most notably a simple data structure with O(1) worst-case decrease-key — keeping the area alive (Section 10).

Key references

  • J. Vuillemin. A data structure for manipulating priority queues. CACM 21(4):309–315, 1978.
  • M. R. Brown. Implementation and analysis of binomial queue algorithms. SIAM J. Comput. 7(3):298–319, 1978.
  • M. L. Fredman, R. E. Tarjan. Fibonacci heaps and their uses in improved network optimization algorithms. JACM 34(3):596–615, 1987.
  • G. S. Brodal. Worst-case efficient priority queues. SODA 1996, 52–58.
  • G. S. Brodal, C. Okasaki. Optimal purely functional priority queues. JFP 6(6):839–857, 1996.
  • H. Kaplan, R. E. Tarjan. Purely functional, real-time deques with catenation. JACM 46(5):577–603, 1999.
  • C. Okasaki. Purely Functional Data Structures. Cambridge University Press, 1998. Chapters 6, 9.
  • B. Chazelle. The soft heap: an approximate priority queue with optimal error rate. JACM 47(6):1012–1027, 2000.
  • G. S. Brodal, G. Lagogiannis, R. E. Tarjan. Strict Fibonacci heaps. STOC 2012, 1177–1184.
  • T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein. Introduction to Algorithms, 3rd ed., MIT Press, 2009, Chapter 19 ("Binomial Heaps") and Chapter 20 ("Fibonacci Heaps").

The binomial heap is, in the end, a piece of mathematics rendered as code: every line of the implementation is the consequence of a binomial identity, and every complexity bound is a corollary of binary arithmetic.