DAA Unit-2 notes
DAA Unit-2 notes
The above Fibonacci Heap consists of five rooted min-heap-ordered trees with 14 nodes.
The min-heap-ordered tree means the tree which holds the property of a min-heap. The
dashed line shows the root list. The minimum node in the Fibonacci heap is the node
containing the key = 3 pointed by the pointer FH-min.
Here, 18, 39, 26, and 35 are marked nodes, meaning they have lost one child. The
potential of the Fibonacci series = No. of rooted tree + Twice the number of marked nodes
= 5 + 2 * 4 = 13. Let us now observe the above example with the complete representation
of the Fibonacci Heap:
In the above figure, we can observe that each node contains four pointers, the parent
points to the parent (Upward), the child points to the child (downward), and the left and
right pointers for the siblings (sideways).
Operations on a Fibonacci Heap:
1. Insertion
Inserting a node into an already existing heap follows the steps below.
1. Create a new node for the element.
3. If the heap is empty, set the new node as a root node and mark it min.
4. Else, insert the node into the root list and update min.
2. Union
Union of two fibonacci heaps consists of following steps.
2. Update min by selecting a minimum key from the new root lists.
3. Extract Min
It is the most important operation on a fibonacci heap. In this operation, the node with
minimum value is removed from the heap and the tree is re-adjusted.
2. Delete the min node, add all its child nodes to the root list and set the min-pointer
to the next root in the root list.
3. The maximum degree in the tree is 3. Create an array of size 4 and map degree
of the next roots with the array.
4. Here, 23 and 7 have the same degrees, so unite them.
A fibonacci heap is a tree based data structure which consists of a collection of trees
with min heap or max heap property. Its operations are more efficient in terms of time
complexity than those of its similar data structures like binomial heap and binary heap.
1. Remove x from the current position and add it to the root list.
Cascading-Cut
Example: Decreasing 35 to 5
2. Cut part: Since 26 ≠ nill and 5<its parent, cut it and add it to the root list.
3. Cascading-Cut part: Since 26 is marked, the flow goes to Cut and Cascading-
Cut.
Cut(26): Cut 26 and add it to the root list and mark it as false.
4. Cascading-Cut(24):
Since the 24 is also marked, again call Cut(24) and Cascading-Cut(7). These
operations result in the tree below.
This process makes use of decrease-key and extract-min operations. The following
steps are followed for deleting a node.