Skip to content
Home » Fibonacci heaps

Fibonacci heaps


Fibonacci Heaps — Detailed Explanation

A Fibonacci Heap is an advanced priority queue data structure that supports extremely fast amortized time for operations—especially decrease-key and merge.

It is widely used in graph algorithms like Dijkstra and Prim, where decrease-key operations happen frequently.


1. What is a Fibonacci Heap?

A Fibonacci Heap is a collection of heap-ordered trees (usually min-heap).
It is similar to a Binomial heap but far more flexible.

Key idea:
👉 Fibonacci Heaps delay work until absolutely necessary, reducing amortized time.


2. Structure of a Fibonacci Heap

A Fibonacci Heap consists of:

  • Root list → list of tree roots
  • Child lists → children of each node
  • Marked nodes → indicates if node has lost a child
  • A pointer to minimum node

Nodes are stored in circular doubly linked lists, allowing O(1) insertion and merging.


3. Properties of Fibonacci Heap

  1. Each tree obeys min-heap property
  2. The structure is very relaxed—trees are not strictly binomial
  3. Trees will become binomial-like only during consolidation
  4. Node has:
    • key value
    • degree (#children)
    • mark bit
    • parent pointer
    • child pointer
    • left/right sibling pointers

4. Key Operations

Fibonacci Heaps are designed to excel in operations that traditional heaps do slowly.


A. Make-heap

Creates an empty heap.
Time → O(1)


B. Find-min

Return pointer to the minimum node.
Stored directly → O(1)


C. Insert(key)

  1. Create new singleton tree.
  2. Insert it into the root list.
  3. Update min pointer.

Time → O(1) amortized

This is faster than binary heap or binomial heap.


D. Merge (Union)

To merge H1 and H2:

  • Concatenate their root lists.
  • Update min pointer.

Time → O(1)
(Far better than Binomial Heap’s O(log n))


E. Extract-min (Delete-min)

Most important and most expensive operation.

Steps:

  1. Remove the min node.
  2. Add all its children to root list.
  3. Consolidate root list:
    • Combine trees of same degree
    • Use linking similar to binomial heaps
    • Ensures at most O(log n) trees remain

Time → O(log n) amortized


F. Decrease-key (Most Important Operation)

This is where Fibonacci Heaps beat all other heaps.

Steps:

  1. Reduce the key value.
  2. If heap-order is violated:
    • Cut the node and move it to root list
    • Cascade cut:
      • If parent is marked → cut parent too
      • Continue up the tree

Time → O(1) amortized
(This is the main reason Dijkstra becomes faster.)


G. Delete

  1. Decrease-key to (-\infty)
  2. Extract-min

Time → O(log n)


5. Amortized Time Complexities

OperationFibonacci HeapBinomial HeapBinary Heap
Make-heapO(1)O(1)O(1)
Find-minO(1)O(log n)O(1)
InsertO(1)O(log n)O(log n)
MergeO(1)O(log n)O(n)
Extract-minO(log n)O(log n)O(log n)
Decrease-keyO(1)O(log n)O(log n)
DeleteO(log n)O(log n)O(log n)

Highlight:
Decrease-key & merge = O(1) → extremely useful for graph algorithms.


6. Applications

Fibonacci Heaps are used for algorithms requiring frequent decrease-key:

A. Dijkstra’s Shortest Path Algorithm

  • Using binary heap → O((V+E) log V)
  • Using Fibonacci heap → O(E + V log V) (faster)

B. Prim’s Minimum Spanning Tree

  • Better performance due to decrease-key = O(1)

C. Network routing tables

D. Event-driven simulation systems

E. Optimal merging of lists

Note: Real-world implementations often use pairing heaps due to simplicity, but Fibonacci heaps remain important theoretically.


7. Advantages of Fibonacci Heaps

✔ Very fast amortized time
✔ Best in theory for graph algorithms
✔ Fast merge operation
✔ Supports cascading cuts to maintain efficiency
✔ Flexible structure (lazy organization)


8. Disadvantages

✘ Complex to implement
✘ High constant factors → slower in practice
✘ Uses more memory
✘ Consolidation step can be tricky
✘ Rarely used in industry (pairing heap preferred)


9. Fibonacci Heap vs Binomial Heap

FeatureFibonacci HeapBinomial Heap
StructureFlexibleStrict binomial
MergeO(1)O(log n)
Decrease-keyO(1)O(log n)
Extract-minO(log n)O(log n)
ImplementationComplexEasier
Graph AlgorithmsBestGood

Summary

A Fibonacci Heap is a powerful priority queue structure that uses:

  • Lazy merging
  • Cascading cuts
  • Consolidation
  • Multiple heap-ordered trees

Its amortized O(1) decrease-key and insert make it extremely valuable in theoretical optimization and graph algorithms.