0% found this document useful (0 votes)
55 views3 pages

Fibonacci Heap - Extract Min and Consolidate, Decrease Key

Uploaded by

097Shashank Sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views3 pages

Fibonacci Heap - Extract Min and Consolidate, Decrease Key

Uploaded by

097Shashank Sahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

KIET Group of Institutions, Ghaziabad

Department of Computer Applications


(An ISO – 9001: 2015 Certified & ‘A’ Grade accredited Institution by NAAC)
Design and Analysis of Algorithm
KCS 503: Session 2020-21
Unit-2 Lecture-27 Topic: Fibonacci Heap
Video Link

Extract_min():

We create a function for deleting the minimum node and setting the min pointer to the minimum value
in the remaining heap. The following algorithm is followed:

1. Delete the min node.


2. Set head to the next min node and add all the tree of the deleted node in root list.
3. Create an array of degree pointers of the size of the deleted node.
4. Set degree pointer to current node.
5. Move to the next node.
If degrees are different then set degree pointer to next node.
If degrees are same then join the Fibonacci trees by union operation.
6. Repeat steps 4 and 5 until the heap is completed.
KIET Group of Institutions, Ghaziabad
Department of Computer Applications
(An ISO – 9001: 2015 Certified & ‘A’ Grade accredited Institution by NAAC)
Design and Analysis of Algorithm
KCS 503: Session 2020-21
Decrease_key():
To decrease the value of any element in the heap, we follow the following algorithm:

1. Decrease the value of the node ‘x’ to the new chosen value.
2. CASE 1) If min heap property is not violated,
Update min pointer if necessary.
3. CASE 2) If min heap property is violated and parent of ‘x’ is unmarked,
Cut off the link between ‘x’ and its parent.
Mark the parent of ‘x’.
Add tree rooted at ‘x’ to the root list and update min pointer if necessary.
4. CASE 3)If min heap property is violated and parent of ‘x’ is marked,
Cut off the link between ‘x’ and its parent p[x].
Add ‘x’ to the root list, updating min pointer if necessary.
Cut off link between p[x] and p[p[x]].
Add p[x] to the root list, updating min pointer if necessary.
If p[p[x]] is unmarked, mark it.
Else, cut off p[p[x]] and repeat steps 4.2 to 4.5, taking p[p[x]] as ‘x’.
KIET Group of Institutions, Ghaziabad
Department of Computer Applications
(An ISO – 9001: 2015 Certified & ‘A’ Grade accredited Institution by NAAC)
Design and Analysis of Algorithm
KCS 503: Session 2020-21
Deletion ():
To delete any element in a Fibonacci heap, the following algorithm is followed:
1. Decrease the value of the node to be deleted ‘x’ to minimum by Decrease_key() function.
2. By using min heap property, heapify the heap containing ‘x’, bringing ‘x’ to the root list.
3. Apply Extract_min() algorithm to the Fibonacci heap.

You might also like