Fibonacci Heap: Delay the Cleanup
A Fibonacci heap is a heap-based priority queue built around one central idea: postpone expensive structural cleanup until it is necessary. Instead of forcing the data structure into a tightly organized shape after every operation, a Fibonacci heap permits temporary disorder. Later, usually when the minimum element is extracted, the heap performs the consolidation work needed to organize its trees.
This strategy is called lazy consolidation. It gives several operations excellent amortized performance, especially insertion, finding the minimum, melding two heaps, and decreasing a key. Fibonacci heaps are therefore useful as priority queues and as a classic example of amortized analysis: an individual operation may occasionally be expensive, but a sequence of operations can still have a strong overall bound.
The word “heap” still refers to an ordering invariant. In a min-Fibonacci heap, every parent has a key no greater than the keys of its children. The structure is different from a conventional binary heap, however. A Fibonacci heap is not one complete binary tree stored in an array. It is a collection of heap-ordered trees connected through a root list. Those trees may have different shapes, and the heap delays combining them until extraction requires consolidation.
1. The heap invariant
A min-heap stores its smallest key at the top. For every node that has a parent, the heap-order property is:
parent.key <= child.key
For example, this is a valid min-heap:
3
/ \\
8 5
/ \\
12 10
The root contains 3, which is no greater than either child. The node containing 8 is no greater than 12 and 10. The value 5 has no children, so it cannot violate the parent-child rule.
A max-heap reverses the comparison:
parent.key >= child.key
In a max-heap, the largest key is at the top. Fibonacci heaps can be defined in either form, although min-heaps are especially common in priority-queue discussions because they naturally support repeatedly selecting the smallest pending value.
The heap invariant is deliberately weaker than the ordering invariant of a binary search tree. A heap requires only a parent-to-child relationship. It does not require every value in the left subtree to be smaller than every value in the right subtree. Consequently, a heap provides efficient access to an extreme element, not efficient search for an arbitrary key.
For a min-heap, the invariant can be summarized as follows:
- every tree is heap-ordered;
- every root is the top of a valid heap-ordered tree;
- the minimum pointer identifies the root with the smallest key.
A Fibonacci heap may contain several separate trees, but that does not mean its invariant is broken. Each tree is valid on its own, and the minimum among the roots is the minimum among all nodes. Every descendant is no smaller than the root above it, so no descendant can be smaller than the minimum root.
2. Conventional binary heaps and complete trees
To understand the design of a Fibonacci heap, it helps to contrast it with an ordinary binary heap.
A conventional binary heap is usually one complete binary tree. Every level is full except possibly the last, and the final level is filled from left to right. This strict shape allows the tree to be represented compactly in an array without storing explicit pointers between parent and child nodes.
With zero-based indexing, a node at array index i commonly has:
left child = 2i + 1
right child = 2i + 2
Its parent is usually located at:
parent = floor((i - 1) / 2)
When a value is inserted, it is placed at the next open array position. That preserves completeness, but the new value might violate the heap-order property with its parent. The operation called sift-up or bubble-up repeatedly swaps the value with its parent until the invariant is restored.
For example, consider this min-heap:
4
/ \\
7 9
/
12
If 2 is inserted, completeness requires it to occupy the next available position. It initially appears below 7, then moves upward because it is smaller than its parent:
4 2
/ \\ / \\
7 9 -> 4 9
/ /
2 7
Extraction works in the opposite direction. The root is removed, the last array element is moved to the root position, and sift-down swaps it with the smaller child until the parent-child ordering is valid again.
Because a complete binary tree has height O(log n), both insertion and extraction take O(log n) time. The strict shape is valuable: it keeps the tree shallow, makes the representation compact, and often gives good practical performance.
A Fibonacci heap makes a different trade-off. It does not insist on one complete tree after every operation. Instead, it allows a forest of trees and performs less immediate restructuring.
3. The Fibonacci-heap forest and root list
A Fibonacci heap is a collection of heap-ordered trees, often called a forest. The roots of those trees are connected through a circular, doubly linked list called the root list.
A typical implementation maintains information such as:
- a pointer to the root with the smallest key;
- the number of nodes in the heap;
- a circular doubly linked list of roots;
- for each node, a pointer to its parent;
- a pointer to one of its children, if it has any;
- pointers to neighboring siblings or roots;
- a degree recording the number of direct children;
- a mark used by cascading cuts.
The exact fields and representation can vary, but the purpose is consistent: the heap needs to move roots and children between circular lists efficiently, link trees during consolidation, and track the minimum without scanning the entire structure on every operation.
A small Fibonacci heap might look conceptually like this:
3 7 11
/ \\ |
8 14 18
The roots 3, 7, and 11 belong to the root list. The minimum pointer refers to 3. Every tree is heap-ordered. The root list may appear disorganized, but that disorder is intentional. The heap does not immediately combine all roots into a balanced arrangement after each insertion.
This is the essential design difference:
- a binary heap maintains a complete tree continuously;
- a Fibonacci heap maintains heap order while allowing a loose forest structure;
- a binary heap repairs shape and order during individual updates;
- a Fibonacci heap delays some structural repair until extraction.
The structure is still a heap because its ordering invariant is preserved. What is deferred is not validity, but organization.
4. Finding the minimum
A Fibonacci min-heap stores a direct pointer to the root with the smallest key. Therefore, find-min simply returns that node. It does not scan every node and does not need to inspect every root.
Suppose the root list contains roots with keys 4, 9, and 15, and the minimum pointer refers to 4. Finding the minimum returns 4 immediately. If another root with key 6 is added, the minimum remains 4. If a root with key 2 is added, the pointer changes to 2.
The operation preserves the heap invariant because every root is the top of a valid heap-ordered tree. Among all roots, the smallest root must also be the smallest node in the entire forest. No descendant can be smaller than its ancestor in a min-heap.
With a maintained minimum pointer, find-min takes O(1) time. This field must be updated carefully whenever a new root is inserted, a node is cut, or extraction removes the current minimum.
5. Insertion: adding a new root
Insertion is one of the clearest examples of Fibonacci-heap laziness.
In an array-based binary heap, a new element must be placed in the next available position in the complete tree. It may then need to move upward through several parent-child relationships. The operation uses sift-up and takes O(log n) time in the worst case.
In a Fibonacci heap, a newly inserted element becomes a one-node tree. It is added directly to the root list. Because it has no parent and no children, it cannot violate the heap-order invariant.
Suppose the current root list is:
4, 7, 13
Inserting 6 gives:
4, 7, 13, 6
The minimum remains 4. Inserting 2 gives another root and changes the minimum pointer:
4, 7, 13, 6, 2
No existing tree is touched, and no root is linked beneath another root. With constant-time circular-list operations, insertion takes O(1) actual time and O(1) amortized time.
The heap is not ignoring the invariant. It is preserving it in the easiest possible way: the inserted node has no parent relationship that could be violated. Any broader organization of the root list is postponed.
6. Lazy meld
A meld, also called a union, combines two heaps into one. This operation is particularly natural for Fibonacci heaps because each heap already exposes its roots as a linked list.
Suppose one heap has roots:
Heap A: 3, 12
and another has:
Heap B: 5, 8
Melding them concatenates the two root lists:
Combined root list: 3, 12, 5, 8
The new minimum pointer refers to 3, the smaller of the two old minima. The node counts are added. No tree needs to be traversed, copied, or rebuilt.
A circular doubly linked list can be concatenated with a small number of pointer changes. Therefore, meld takes O(1) actual time and O(1) amortized time in the standard Fibonacci-heap model.
The cost of this convenience is deferred organization. After many melds, the root list may contain many separate trees, perhaps with equal degrees. That is acceptable because the heap remains valid. Later, extract-min will consolidate roots and pay some of the accumulated cleanup cost.
This illustrates a general data-structure principle: a structure can make union cheap by storing components in a form that can be joined directly. The resulting structure may be less tidy, but it can preserve the operations that matter most for the workload.
7. Extract-min: where cleanup happens
The operation that normally performs deferred cleanup is extract-min. It removes and returns the node with the smallest key.
A typical extract-min proceeds through these stages:
- Identify the minimum root.
- Remove that root from the root list.
- Move all of its children into the root list.
- Consolidate roots with equal degrees.
- Scan the remaining roots and update the minimum pointer.
Consider a minimum root with key 3 and three children:
3
/ | \\
8 10 14
When 3 is removed, its children become roots:
8, 10, 14, plus the other roots already in the heap
This promotion is safe because each child already heads a heap-ordered subtree. Once the parent is gone, the child has no parent constraint to violate. Its descendants remain attached, and the subtree remains valid.
After promotion, the root list may contain many trees with the same degree. Consolidation reduces this duplication. If two roots have degree d, one is linked beneath the other. In a min-heap, the root with the smaller key becomes the parent. The resulting tree has degree d + 1.
For example, two degree-two roots might be represented as:
4 7
/ \\ / \\
9 12 8 15
Because 4 < 7, the root 7 becomes a child of 4. The resulting tree has one root and degree three:
4
/ | \\
9 12 7
/ \\
8 15
The exact order of children is not important. The important fact is that the smaller root remains above the larger root, so linking preserves heap order.
After all possible equal-degree links are performed, the remaining roots have distinct degrees, or at least have been reduced to a controlled collection. The heap then scans them to find the new minimum. Extract-min has O(log n) amortized complexity in a standard Fibonacci heap.
8. Degree consolidation
Consolidation can be understood as repeatedly combining roots that have the same degree. A node’s degree is the number of its direct children. A one-node tree has degree 0; a root with two direct children has degree 2.
The algorithm commonly uses an auxiliary array indexed by degree. As it examines each root:
- Look at the root’s degree.
- If the corresponding degree slot is empty, store the root there.
- If another root already occupies that slot, compare their keys.
- Link the larger-key root beneath the smaller-key root in a min-heap.
- Increase the surviving root’s degree and repeat with the new degree.
Suppose the roots have degrees:
0, 0, 1, 1, 1, 3
The two degree-zero trees link into one degree-one tree. That new tree may collide with existing degree-one trees. Further links can produce degree-two trees, which may collide again. The process resembles carrying in binary addition: two objects of one rank combine into one object of the next rank.
Consolidation does not sort all keys. It does not impose a complete-tree layout, and it does not produce a binary search tree. It only combines roots according to degree while preserving the heap-order relationship.
For a max-Fibonacci heap, the process is identical except that the larger key remains the parent. The tracked extreme pointer is the maximum pointer rather than the minimum pointer.
9. Decrease-key and cuts
Decrease-key lowers the key of an existing node in a min-Fibonacci heap. The operation is valuable in priority queues where an item’s priority improves after it has already been inserted.
Suppose a node has key 20 and its parent has key 12. Lowering the node to 15 is safe because 12 <= 15. Lowering it to 5 creates a violation:
Before: parent 12, child 20
After: parent 12, child 5
The Fibonacci-heap repair is to cut the node from its parent and add it to the root list:
Before:
12
|
5
After:
12 5
The node 5 is now a root, so it has no parent relationship to violate. If its key is smaller than the current minimum, the minimum pointer is updated.
If the cut node has children, those children remain attached to it. Lowering the node’s key cannot create a violation with its children in a min-heap, because the node has become smaller, not larger. The important violation was between the changed node and its former parent.
A cut changes the forest structure but preserves heap order. This is another contrast with a binary heap, where decrease-key typically moves a value upward through a fixed array path using swaps. A Fibonacci heap changes the tree boundary instead.
10. Mark bits and cascading cuts
A single cut is not the whole decrease-key story. Fibonacci heaps also use mark bits and cascading cuts to prevent a non-root node from losing too many children while remaining deeply attached to its parent.
The usual rule is:
- a root is treated separately because it has no parent;
- when an unmarked non-root loses one child, it becomes marked;
- when a marked non-root loses another child, it is cut from its parent;
- the same rule may then apply to the parent, producing a cascade.
Consider a chain of parent-child relationships:
A
|
B
|
C
Assume B has already lost one child and is marked. If a later decrease-key operation causes another child of B to be cut, B is also cut from A and moved to the root list. If A is a marked non-root, it may be cut as well.
The cuts restore local heap order. Every node whose key became too small to remain under its parent is detached. The marking rule limits how much a node can weaken before it is promoted to the root list.
A cascade can be long during one particular operation, so the actual worst-case time of decrease-key is not necessarily constant. Fibonacci heaps obtain an O(1) amortized bound by accounting for the work across a sequence of operations. The potential stored in roots and marked nodes helps pay for later cuts.
11. Amortized analysis: paying later
Amortized analysis studies the total cost of a sequence rather than promising that every individual operation is equally cheap. A data structure may deliberately perform little work now and accumulate a structural obligation that will be paid later.
A common potential function for a Fibonacci heap has the general form:
potential = number of roots + a constant times number of marked nodes
The exact constant belongs to the formal proof. The intuition is that roots and marks represent stored structural work.
An insertion creates a new root. The immediate pointer changes are cheap, while the increased number of roots contributes to the potential. That potential can help pay for links performed during a future extract-min.
A meld joins root lists. It is cheap immediately, but the combined root list may contain more trees that eventually need consolidation. Again, the deferred work is represented by the potential.
A decrease-key may cut one or more nodes and move them to the root list. The operation can be physically involved when cascading cuts occur, but the removal of marks and the changes to the root structure affect the potential. The decrease in stored potential helps account for the pointer operations.
Extract-min consumes some of the accumulated potential while removing roots and consolidating equal-degree trees. The result is a strong sequence-level bound even though a specific extraction can be much more expensive than a specific insertion.
The phrase delay the cleanup captures this accounting strategy. Fibonacci heaps do not eliminate structural work. They postpone it so that operations such as insertion, meld, and decrease-key can remain very inexpensive in amortized terms.
12. Why the degree is logarithmic
Degree consolidation is efficient only if node degrees are controlled. If a single node could have an arbitrarily large number of children relative to the heap size, extraction might require too much work and the logarithmic bounds would fail.
The Fibonacci-heap rules provide the necessary control. Linking equal-degree trees increases a parent’s degree in a structured way. The rules for marks and cascading cuts prevent a non-root node from losing too many children without itself being cut. As a result, a node of degree d must have a subtree containing a rapidly growing number of nodes.
The minimum subtree size follows a growth pattern related to Fibonacci numbers, which gives the data structure its name. The exact proof is more involved than the operational description, but the important consequence is:
maximum degree = O(log n)
where n is the number of nodes.
This bound means that the degree array used during consolidation has only logarithmically many relevant positions. It also explains why extract-min has an O(log n) amortized bound rather than a linear one.
This does not mean Fibonacci trees are complete or perfectly balanced. They can have irregular shapes. The guarantee is more specific: the degree of a node is bounded relative to the total number of nodes, and the potential analysis accounts for temporary irregularity.
13. Complexity summary
For a standard Fibonacci min-heap, the commonly stated amortized bounds are:
| Operation | Amortized complexity | Main idea |
|---|---|---|
| Create an empty heap | O(1) | Initialize the heap fields |
| Find minimum | O(1) | Return the minimum pointer |
| Insert | O(1) | Add a one-node tree to the root list |
| Meld | O(1) | Concatenate two root lists |
| Decrease-key | O(1) | Cut and possibly cascade, paid for amortized |
| Extract-min | O(log n) | Promote children and consolidate degrees |
| Delete | O(log n) amortized | Use decrease-key followed by extraction |
The word “amortized” is essential. It does not mean that every operation takes constant or logarithmic time in isolation. One decrease-key may trigger a cascade, and one extract-min may consolidate many roots. The bounds apply to suitable sequences under the standard analysis.
For comparison, a conventional binary min-heap typically has:
| Operation | Typical complexity |
|---|---|
| Find minimum | O(1) |
| Insert | O(log n) |
| Meld | Not naturally constant-time |
| Decrease-key | O(log n) |
| Extract-min | O(log n) |
| Build from an array | O(n) |
Fibonacci heaps are theoretically attractive when a workload contains many insertions, melds, and decrease-key operations relative to extract-min operations. A binary heap may still be preferable when implementation simplicity, compact storage, cache behavior, or predictable individual operation costs are more important.
14. Sift-up, sift-down, and heapify in context
The terms sift-up, sift-down, and heapify are most closely associated with array-based binary heaps. Comparing them with Fibonacci-heap operations clarifies the different design philosophies.
Sift-up
Sift-up repairs a violation between a node and its parent. In a binary min-heap, a newly inserted value begins at the bottom because the complete-tree shape must be maintained. If it is smaller than its parent, it swaps upward until the invariant is restored.
A Fibonacci heap does not need this operation for insertion. The new item becomes a root, so there is no parent comparison to violate. Decrease-key follows a related idea: instead of swapping a newly smaller node upward through a path, it cuts the node from its parent and makes it a root.
Sift-down
Sift-down repairs a violation between a node and its children. During binary-heap extraction, the last array element is moved to the root and may be larger than one of its children. It swaps downward with the smaller child in a min-heap until order is restored.
A Fibonacci heap normally does not move one replacement value down a complete tree after extract-min. It removes the minimum root, promotes all of its children, and then links roots with equal degrees. The repair is performed through forest-wide consolidation rather than one downward path.
Heapify
Heapify may refer to repairing a local violation or to building a heap from an unordered array. Bottom-up construction of an array binary heap takes O(n) time because most nodes are near the leaves and have short possible sift-down paths.
A Fibonacci heap can be built by repeated insertion. Since each insertion is O(1) amortized, inserting n values takes O(n) total amortized time, although the resulting heap may contain many roots until extraction consolidates them.
These approaches maintain the same basic heap-order concept but choose different moments for structural work. Binary heaps keep shape and order tightly controlled. Fibonacci heaps preserve order and defer shape management.
15. Fibonacci heaps versus binary search trees
A Fibonacci heap and a binary search tree may both be drawn as connected nodes, but they support different operations and obey different invariants.
A binary search tree is designed for ordered searching. Its invariant places values in the left subtree according to one ordering relationship and values in the right subtree according to the opposite relationship. In a balanced binary search tree, search, insertion, deletion, predecessor, successor, and some range operations can be efficient.
A heap is designed for priority access. In a min-heap, the root is no greater than its children, but two unrelated branches are not globally sorted. For example:
2
/ \\
9 5
/ \\ / \\
20 11 8 13
This is a valid min-heap. The value 8 can appear in the right subtree while 9 appears in the left subtree. The heap does not require one entire subtree to be ordered relative to the other.
Therefore, finding an arbitrary value in a heap may require examining many nodes. A Fibonacci heap is not a replacement for a search tree. It is a priority queue structure that makes access to the minimum or maximum efficient.
Fibonacci heaps are even less tied to a single shape than ordinary binary heaps. They consist of a forest and a root list, and their trees can be irregular. Their organization is selected for priority-queue operations such as insert, meld, decrease-key, and extract-min.
16. Delete through decrease-key
Deletion of an arbitrary node is commonly explained using decrease-key. In a min-Fibonacci heap, reduce the target’s key to a value smaller than every valid key, conceptually negative infinity. This moves the target toward the root list through the cut rules. Then extract the minimum.
The conceptual sequence is:
decrease-key(target, -infinity)
extract-min()
The extract-min step removes the target because it is now the smallest item. The amortized complexity is O(log n), dominated by extraction.
A production implementation should define how the extreme temporary value is represented. If ordinary numeric keys are allowed, a magic sentinel may conflict with a legitimate user value. An implementation can instead use a comparison policy or a dedicated deletion state. The important algorithmic idea is that decrease-key exposes the target as the next minimum, after which extraction removes it.
17. An end-to-end example
Start with an empty min-Fibonacci heap and insert 10, 4, 15, and 7.
Each value becomes a separate root:
Root list: 10, 4, 15, 7
Minimum: 4
No links are needed. The forest is valid even though it has four roots.
Now extract the minimum. The node 4 has no children, so removing it leaves:
Root list: 10, 15, 7
All three roots initially have degree zero. Consolidation links two of them. Suppose 10 and 15 are linked. Since 10 is smaller, 15 becomes its child:
10
|
15
The root list now contains the tree rooted at 10 and the one-node tree rooted at 7. The minimum pointer is updated to 7.
Next, decrease the key of 15 to 3. Its parent is 10, so the heap order is violated. The node is cut and moved to the root list:
Root list: 7, 10, 3
Minimum: 3
The tree rooted at 10 remains valid because the offending child is no longer attached to it. The new root 3 is now the minimum.
This sequence shows the characteristic rhythm of a Fibonacci heap: insertions and key decreases create or expose roots, while extract-min performs the more extensive consolidation work.
18. Implementation considerations
Fibonacci heaps are usually implemented with circular doubly linked lists. These lists support efficient insertion, removal, and concatenation. A node can be detached from a sibling list, and a group of roots can be spliced into the root list using a small number of pointer changes.
Typical node fields include:
key
parent
child
left
right
degree
marked
The child pointer can refer to any one child. The children themselves form a circular list through left and right pointers. A node with no siblings can point to itself in that circular list.
Common helper operations include:
- inserting a node into a circular list;
- removing a node from a circular list;
- concatenating two circular lists;
- moving every child of a node into the root list;
- linking one root beneath another;
- cutting a node from its parent’s child list;
- performing cascading cuts;
- rebuilding the minimum pointer after consolidation.
Pointer updates must be performed carefully. When iterating through a list that is being modified, the implementation should preserve the next node before changing links. When moving children into the root list, it should detach the child list safely before discarding the old parent.
The minimum pointer is especially important. Inserting a smaller root or cutting a node with a smaller key requires an immediate update. After extract-min and consolidation, the remaining roots must be scanned to identify the new minimum.
The pointer-rich representation can have practical costs. Compared with an array-based binary heap, it may use more memory and provide weaker locality. Allocation overhead, cache behavior, language-runtime details, and the operation mix can all affect observed performance. Asymptotic advantages are important, but they do not eliminate engineering trade-offs.
19. Practical use cases
The most natural use case for a Fibonacci heap is a priority queue with frequent priority updates. In such a workload, an item may be inserted once and then have its key decreased several times before it is finally extracted.
Fibonacci heaps are also attractive when multiple priority queues need to be combined. Their lazy meld operation can join two heaps without rebuilding either one.
Typical algorithmic patterns include:
- priority queues with frequent decrease-key operations;
- graph algorithms that maintain tentative distances or connection costs;
- event-oriented systems where priorities change and queues are merged;
- theoretical algorithm analyses requiring strong amortized bounds for meld and decrease-key.
A Fibonacci heap is not automatically the best implementation for every priority queue. If the workload consists mostly of insert and extract-min, a binary heap may be easier to implement and fast enough. If priorities are integers in a restricted range, a specialized priority structure may be more suitable. If each individual operation needs a strict worst-case guarantee, amortized bounds may not satisfy the requirement.
The correct choice depends on the operation mix and environment. Fibonacci heaps are most compelling when their specific strengths—constant amortized insertion, meld, and decrease-key—are central to the workload.
20. Heap sort and the binary-heap contrast
Heap sort is commonly taught using an array-based binary heap. One approach builds a max-heap from an array, repeatedly extracts the maximum, and places each extracted value at the end of the array. The total running time is O(n log n).
A Fibonacci heap can also be used as a priority queue for sorting. Insert all n values and repeatedly extract the minimum. The n insertions take O(n) total amortized time, while the n extractions contribute O(n log n), giving an overall O(n log n) bound.
That does not make a Fibonacci heap the usual practical choice for heap sort. Array-based binary heaps have compact storage, simple index arithmetic, and good memory locality. Fibonacci heaps are designed to optimize a broader operation set, particularly meld and decrease-key, rather than to provide the simplest in-place sorting mechanism.
This contrast highlights a broader lesson: an improved bound for one operation does not automatically make a data structure better for every task. Choose the structure according to the operations that dominate the workload.
21. Min-heaps and max-heaps
The same architecture can support either ordering direction.
In a min-Fibonacci heap:
- the smallest root is tracked;
- the smaller key wins when equal-degree trees are linked;
- decreasing a key can violate the parent-child order;
- extract-min removes the smallest root.
In a max-Fibonacci heap:
- the largest root is tracked;
- the larger key wins when equal-degree trees are linked;
- increasing a key is the analogous priority-update operation;
- extract-max removes the largest root.
The structure—root list, heap-ordered trees, lazy operations, cuts, marks, and degree consolidation—remains the same. Only the comparison direction and the name of the tracked extreme change.
When implementing both versions, it is useful to centralize the comparison rule instead of scattering less-than and greater-than tests throughout the code. Consistent comparisons are essential for linking, updating the extreme pointer, and deciding whether a key update violates heap order.
22. Common misconceptions
A Fibonacci heap is not an array of Fibonacci numbers
The name refers to the Fibonacci-number growth pattern used in the degree analysis. The data structure is a linked collection of heap-ordered trees.
Every operation is not constant-time
Insertion, find-min, meld, and decrease-key are commonly described as O(1) amortized. Extract-min is O(log n) amortized. These statements describe different operations and should not be compressed into the claim that “a Fibonacci heap is constant-time.”
Multiple roots do not violate the invariant
A heap can contain many roots. The invariant concerns parent-child relationships. Each root is valid, and the minimum pointer identifies the smallest root.
A heap is not sorted
The root provides access to the minimum or maximum, but the remaining nodes are not globally ordered. To obtain all values in priority order, repeated extraction is still required.
Cascading cuts are controlled repairs
Marks and cascading cuts are not arbitrary restructuring. They prevent non-root nodes from losing too many children while remaining deep in a tree. This control supports the degree bound needed for efficient consolidation.
23. Practical takeaways
The main ideas can be summarized as follows:
- A Fibonacci heap is a forest, not a complete binary tree. Its roots are stored in a circular root list.
- The heap invariant is local. In a min-heap, every parent key is no greater than the keys of its children.
- Insertion is lazy. A new item becomes a one-node root instead of being sifted upward through a complete tree.
- Meld is lazy. Two root lists can be concatenated without rebuilding the trees.
- Decrease-key uses cuts. If lowering a key violates the parent relationship, the node is detached and becomes a root.
- Marks and cascading cuts limit structural damage. They keep trees sufficiently controlled for degree analysis.
- Extract-min performs cleanup. It promotes the minimum’s children and consolidates roots with equal degrees.
- The complexity bounds are amortized. Several operations are
O(1)amortized, while extract-min isO(log n)amortized. - Fibonacci heaps differ from binary heaps in strategy. Binary heaps maintain a complete tree continuously; Fibonacci heaps defer consolidation.
- Fibonacci heaps differ from search trees in purpose. They provide priority access rather than efficient arbitrary-key search.
The design can be remembered as a scheduling decision: perform only the local work required to keep heap order valid, and postpone global organization until an operation such as extract-min needs it. That decision produces powerful amortized bounds and makes Fibonacci heaps a classic example of how deferred work can improve the performance of an entire operation sequence.