The strength of Fibonacci heaps lies in their use of circular doubly linked lists and lazy restructuring, which enables constant-time operations and amortized complexities.

Merge Operation

The merge operation combines two Fibonacci heaps, and , by joining their root lists, i.e. concatenating two circular doubly linked lists:

  1. Bi-directionally, connect the rightmost sibling of to the leftmost sibling of
  2. Bi-directionally, connect the leftmost sibling of to the rightmost sibling of .
  3. Set H.min as the min(H₁.min, H₂.min)

Since root lists are circular and accessible via their minimum nodes, merging takes time.

Insertion Operation

The insert operation adds a new node to a Fibonacci heap in time as follows:

  1. Access the heap via the H.min pointer
  2. Insert the new node into the root_list, typically as the left sibling of H.min
  3. If the new node’s key is smaller than H.min, update H.min to point to the new node.

Insertion is done to the left for consistency, though the position is arbitrary due to the unordered nature of the root list.

Extract-Min Operation

The extract-min operation removes the node with the minimum key from the Fibonacci heap:

  1. Identify the minimum node via the H.min pointer.
  2. Remove this node from the root list via delete operation.
  3. Promote all its children to the root list in via pointer manipulation
    • The children, stored in a circular doubly linked list, are spliced directly into the root list.
    • This involves reconnecting:
      • The leftmost child to the node left of the removed node, and
      • The rightmost child to the node right of the removed node.
    • Each promoted child’s parent pointer is set to null.
  4. Set H.min to temporarily to the right sibling of H.min
  5. Run the consolidate operation to merge trees of the same degree

Before consolidation, the root list may contain multiple trees of the same degree. Afterward, the heap maintains at most one tree per degree, restoring the Fibonacci heap properties.

Consolidation Operation

The consolidate operation merges trees of the same degree to ensure the heap contains at most one tree of any given degree, maintaining the Fibonacci heap properties. It only executes after an extract-min operation.

  1. Initialise an auxiliary array A of size with null, where A[d] stores a pointer to a tree root of degree d.
  2. Initialise current = H.min for node traversal and final = current.left to check when a full cycle is complete.
  3. Traverse each node in the root list, ensuring there is at most one tree of any degree
    • Let x = current and d = current.degree
    • If x is the first tree encountered with degree d (i.e. A[d] = null) then:
      • Set A[d] = x
      • Point current to the next distinct node in the root list.
      • If current = final, a full cycle is complete, and at most one tree of any degree exists.
    • Else if another node y has already been encountered with degree d (A[d] != null) then:
      • Merge (consolidate) the two trees together, maintaining the heap-property.
      • Set A[d] = null
      • Point current to the root of the merged tree.
  4. Additionally, during traversal, keep track of the minimum root encountered, and update H.min.

The amortised time complexity of consolidate and extract-min is . This, along with the space complexity of A, is due to the fact that the maximum degree of any node in a Fibonacci heap is see proof

Decrease-Key Operation

The decrease-key operation in a Fibonacci heap reduces the key of a given node to a new, smaller value:

Case 1: When decrease-key(x -> y) does not violate the heap property i.e. parent < y

  1. Simply decrease the key on this node. No restructuring is required.

Case 2: When decrease-key(x -> y) does violate the heap property i.e. parent > y

  1. Promote the subtree rooted at y (previously x) to the root_list
  2. Update H.min if necessary
  3. If y was marked before, unmark it after promoting.
  4. If the parent was originally unmarked (i.e. hasn’t yet lost a child) mark it to indicate that it has lost a child.
  5. Else if the parent was marked, repeat this promotion process with the parent node.

The amortised complexity of decrease-key is

Delete Operation

The delete operation deletes some specified node from the Fibonacci Heap. It can be done simply by:

  1. decrease-key the node to
  2. extract-min

This removes the node in amortised time