Skip to content
Part IA Lent Term

Fibonacci Heaps: The Potential Function

The Potential Method (Review)

For any data structure, define a potential function Φ(D)0\Phi(D) \ge 0 that maps each state DD of the structure to a non-negative real number, with Φ(D0)=0\Phi(D_0) = 0 for the initial (empty) state. The amortised cost of an operation is:

c^i=ci+Φ(Di)Φ(Di1)\hat{c}_i = c_i + \Phi(D_i) - \Phi(D_{i-1})

where cic_i is the actual cost and Φ(Di)Φ(Di1)\Phi(D_i) - \Phi(D_{i-1}) is the change in potential. Over mm operations,

i=1mc^i=i=1mci+Φ(Dm)Φ(D0)i=1mci\sum_{i=1}^{m} \hat{c}_i = \sum_{i=1}^{m} c_i + \Phi(D_m) - \Phi(D_0) \ge \sum_{i=1}^{m} c_i

so amortised costs upper-bound actual costs.

Fibonacci Heap Potential

The potential function for a Fibonacci heap is:

Φ=r+2m\Phi = r + 2m

where:

  • rr = number of trees in the root list (number of roots)
  • mm = number of marked nodes (nodes with marked = true)

Check: For an empty heap, Create returns (NIL, 0), so r=0r = 0, m=0m = 0, and Φ=0\Phi = 0 (valid initial state, non-negative).

Amortised Analysis of Each Operation

Insert

Actual cost: Θ(1)\Theta(1). The new node is added to the root list as a singleton. It is never marked. rr increases by 1; mm unchanged.

ΔΦ=(r+1+2m)(r+2m)=1\Delta \Phi = (r+1 + 2m) - (r + 2m) = 1

c^=Θ(1)+1=Θ(1)\hat{c} = \Theta(1) + 1 = \Theta(1)

Destructive Union

Actual cost: Θ(1)\Theta(1). Root lists are spliced together; no marks change. Combined potential:

Φ=(r1+r2)+2(m1+m2)=Φ1+Φ2\Phi' = (r_1 + r_2) + 2(m_1 + m_2) = \Phi_1 + \Phi_2

ΔΦ=Φ(Φ1+Φ2)=0\Delta \Phi = \Phi' - (\Phi_1 + \Phi_2) = 0

c^=Θ(1)+0=Θ(1)\hat{c} = \Theta(1) + 0 = \Theta(1)

Decrease-Key

Three cases depending on whether cutting occurs:

Case 1 — No cut (new key \ge parent’s key): No structural change. ΔΦ=0\Delta\Phi = 0, c^=Θ(1)\hat{c} = \Theta(1).

Case 2 — Single cut, parent was unmarked: Node x goes to root list (rr +1). x becomes unmarked (if it was marked, mm -1; if not, mm unchanged). Parent p becomes marked (mm +1).

  • If x was unmarked: ΔΦ=(r+1+2(m+1))(r+2m)=3\Delta\Phi = (r+1 + 2(m+1)) - (r + 2m) = 3
  • If x was marked: ΔΦ=(r+1+2(m))(r+2m)=1\Delta\Phi = (r+1 + 2(m)) - (r + 2m) = 1

In both cases, ΔΦΘ(1)\Delta\Phi \in \Theta(1), so c^=Θ(1)\hat{c} = \Theta(1).

Case 3 — Cascading cut: aa nodes are cut and moved to root list. Each cut node was marked (so mm decreases by aa). Each enters the root list (rr increases by aa). The node whose key was decreased also enters the root list (rr +1). The final stop may mark one parent (mm +1, or 0 if parent is a root).

ΔΦ=(r+1+a)+2(ma)(r+2m)=1+a2a=1a\Delta\Phi = (r+1+a) + 2(m-a) - (r+2m) = 1 + a - 2a = 1 - a

Actual cost is k1+ak2k_1 + a \cdot k_2. Setting k2=1k_2 = 1 (each cut takes constant time):

c^=(k1+a)+(1a)=k1+1=Θ(1)\hat{c} = (k_1 + a) + (1 - a) = k_1 + 1 = \Theta(1)

The cascading work is “paid for” by the decrease in mm: each cut node was marked, contributing 2 to the potential; when it is unmarked on entering the root list, those 2 units are released to pay for the cut.

Extract-Min

Actual cost: O(r+D(n))O(r + D(n)) where D(n)D(n) is the maximum degree and rr is pre-operation root list size.

  • Promote children of min (at most D(n)D(n) children): each child joins root list, rr increases by up to D(n)D(n).
  • One root removed.
  • Consolidation scans r+D(n)1r + D(n) - 1 roots, merging trees of equal degree.
  • After consolidation: at most D(n)+1D(n)+1 trees remain.

Potential before: Φ1=r+2m\Phi_1 = r + 2m. Potential after (worst case): Φ2=(D(n)+1)+2m\Phi_2 = (D(n)+1) + 2m. Change: ΔΦ=D(n)+1r\Delta\Phi = D(n)+1 - r.

c^=O(r+D(n))+(D(n)+1r)=O(D(n))\hat{c} = O(r + D(n)) + (D(n) + 1 - r) = O(D(n))

Since D(n)=O(logn)D(n) = O(\log n) (proved by the degree bound), c^=O(logn)\hat{c} = O(\log n). The large rr term in actual cost is cancelled by the corresponding decrease in potential (the “credit” that insert and decrease-key built up).

Intuition Behind the Potential

The term rr pays for scanning the root list during extract-min. Each insert adds 1 to rr and 1 to potential. The term 2m2m pays for cascading cuts: when a node is marked, 2 units are deposited; one unit pays for the cut itself, the other for the node now occupying space in the root list (adding to the cost of future extract-min).

Potential flow diagram

Summary

OperationΔΦ\Delta\PhiAmortised Cost
Insert+1+1Θ(1)\Theta(1)
Destructive-union00Θ(1)\Theta(1)
Decrease-key (no cut)00Θ(1)\Theta(1)
Decrease-key (single cut)11 or 33Θ(1)\Theta(1)
Decrease-key (cascading)1a1-aΘ(1)\Theta(1)
Extract-minD(n)+1rD(n)+1-rΘ(logn)\Theta(\log n)

Key insight: The potential Φ=r+2m\Phi = r + 2m captures the “repair work” deferred by lazy insert and decrease-key operations, releasing credit exactly when extract-min needs to perform consolidation.