Fibonacci Heap
Some Notes about Fibonacci HeapsPermalink
Operations:Permalink
make_heap
Return an empty heapinsert(i,h)
Add item to heap .find_min(h)
Return the smallest item in heapdelete_min(h)
Delete min from heap and return itmeld(h1, h2)
Return the heap formed by putting all elements in with all the elements in . and are destroyed.decrease_key(delta, i, h)
Assume that position of is known. Decrease the value of item of delta (delta > 0)delete(i, h)
Assume that position of is known. Delete from heap
Amortized Time ComplexityPermalink
delete_min(h)
anddelete(i, h)
takes time- Other operations take time
StructurePermalink
- Heap Ordered Trees: Rooted tree containing a set of item, 1 item / node, with items arranged in heap order
- Heap Order: Key of item is no less than the key of the item in its parent , provided has a parent.
- Linking: Combine two item-disjoint trees into one. (Make one root (bigger) a child of the other (smaller))
- Fibonacci heap (F-heap): Collection item disjoint heap ordered trees. (the algorithms impose an additinoal constraint).
- rank : Number of children of node . It turns out that if has descendants, the number of children is at most .
- Nodes will be marked or unmarked.
Representation of F-HeapPermalink
- Each node contains pointer to its parent (or to if it doesn’t have one).
- Each node has a pointer to one of its children (or to if it doesn’t have any).
- The children of each node are in a doubly linked circular list.
- Node has its rank and a bit indicating its mark.
- All the roots of the (sub)heaps are in a circular list.
- There is a pointer to a root containing an item of minimum key ( of the F-heap).
DefinitionsPermalink
- : Collection of Heaps.
- : Potential of .
- operations with times
- amortized time for operation .
- : Potential after operation .
- : Initial potential.
- is initially zero.
- is non-negative.
IdeaPermalink
- Potential of a collection of heaps: The total number of trees they contain.
- Initial potential is zero
make_heap
,find_min
,insert
, andmeld
take time.- Insertion increases the number of trees by one. And other operations do not affect the number of trees
delete_min
: Amorzied time where is the number of items in the heap. Increases the number of trees by at most .- Linking Step: Decreases the number of trees by one.
Implementation of OperationsPermalink
make_heap
Just returfind_min(h)
Return the minimum node ofinsert(i, h)
Create a heap of only node and replace by meld of and the new heapmeld(h1, h2)
Combine the root lists of and into one list and set the minimum node to the appropriate new minimum node.
delete_min(h)
Permalink
- Remove the minimum node () from
- Concatenate the list of children of with the list of roots of (other than )
- Repeat the following Linking Step until it no longer applies
- Find any two trees whose roots have the same rank and link them (the new root has rank +1)
- Form a list of the remaining roots.
- Find the item of minimum key.
Note: Implementation (use an array indexed by ranks).
decrease_key(delta, i, h)
Permalink
- Key of item is decreased by delta
- Cut out the node containing item from its parent
- and its descendants is added as a new tree of .
- The appropriate update operations are performed
delete(i, h)
Permalink
- Find node containing item .
- Cut out the node containing item from its parent.
- Form a new list of roots by concatenating the list of children of with the original list of roots.
- The appropriate update operations are performed.
delete
takes , except when the minimum element is deleted.
Additional Details (Cascade Cut)Permalink
- When node has been made a child of another node by a linking step and it loses 2 of its children through cuts, we cut the edge joining and its parent and we make ad new root (as in
decrease_key
) - A
decrease_key
ordelete
operation my casue a possibly large number of cascading cuts.
Marking NodesPermalink
- Purpose: Keep track of where to make cascade cuts.
- Unmark : When making a root node a child of another node in a linking step
- When curring edge joining and its parent , we decrease the rank of and check it is a root
- if is not a root, we mark it if it is unmarked and cut the edge to its parent it it is marked. (latter cut my be cascading)
- Each cut takes .
Crucial PropertiesPermalink
- Each tree in an F-heap has a size at lease exponential in the rank of its root. i.e. the number of children is at most .
- The number of cascading cutus that take place during a sequence of heap operations is bounded by the number of decrease key and delete operations.
ObservationsPermalink
- The purpose of cascade cuts in to preserve property 1.
- Loss of two children rule limits the frequency of cascade cuts.
Lemma 1: Let be any node in a F-heap. Arrange the children of in the order they were linked to , from earliest to latest. Then the child of has rank of at least .
Corollary 1: A node of rank in an F-heap has at least descendants, including itself, where is the Fibonacci number and is the golden ratio.
RedefinitionPermalink
- Potential: Total numbere of trees plus twice the number of marked nonroot nodes.
- The bounds of for
make_heap
,find_min
,insert
, andmeld
remain valid, as does not bound fordelete_min
. delete_min(h)
: increases the potential by at most minus the number of linking steps, since, if the minimum node has rank , then and thus
Revist decrease_key
Permalink
- Causes potential to increase by at most three mins the number of cascading cuts, since
- the first cut converts a possible unmarked nonroot node into a root
- each cascading cut converts a marked nonroot node into a root
- the last cut can convert a nonroot node from unmarked to marked
- It follows that decrease key has an amortized time bound.
Revist delete
Permalink
Just combine the analysis of decrease_key
with delete_min
SummaryPermalink
If we begin with no F-heaps and perform an arbitrary sequence of F-heap operations, then the total time is at most the total amortized time, where the amortized time is for each delete_min
or delete
, and for each other operations.
Comments