Download presentation
Presentation is loading. Please wait.
Published byAshley Flynn Modified over 8 years ago
1
Fibonacci Heaps
2
Fibonacci Binary insert O(1) O(log(n)) find O(1) N/A union O(1) N/A minimum O(1) O(1) decrease key O(1) O(log(n)) delete O(log(n) O(log(n)) delete minimum O(log(n)) N/A
3
Fibonacci Heaps Binomial Tree: A binomial tree of order 0 is a single node A binomial tree of order k has a root of degree k and its children are roots of binomial trees of orders k-1, k-2,..., 2, 1, 0 (in order). A binomial tree of order k has 2 k nodes
4
Fibonacci Heaps Data Structures: Circular doubly linked list of siblings ( ) All nodes have pointers to their parents One pointer to a child
5
Fibonacci Heaps Forest of binomial trees - key of node is less than keys of children
6
Fibonacci Heaps Forest of binomial trees - key of node is less than keys of children Node with minimum key is a root of one of the trees
7
Fibonacci Heaps Forest of binomial trees - key of node is less than keys of children Node with minimum key is a root of one of the trees A node may have degree greater than 2 but no larger than O(log(n))
8
Fibonacci Heaps Forest of binomial trees - key of node is less than keys of children Node with minimum key is a root of one of the trees A node may have degree greater than 2 but no larger than O(log(n)) Size of a subtree rooted in node of degree k is > F k+2 where F k is the kth Fibonacci number
9
Fibonacci Heaps Forest of binomial trees - key of node is less than keys of children Node with minimum key is a root of one of the trees A node may have degree greater than 2 but no larger than O(log(n)) Size of a subtree rooted in node of degree k is > F k+2 where F k is the kth Fibonacci number 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node
10
Fibonacci Heaps Operation: Find Minimum Simple lookup using Min Node pointer - O(1) 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node
11
Fibonacci Heaps Operation: Union of two heaps Attach higher numbered node to smaller Remove former root from linked list Add former root to children linked list - O(1) 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node
12
Fibonacci Heaps Operation: Union of two heaps Attach higher numbered node to smaller Remove former root from linked list Add former root to children linked list - O(1) 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node
13
Fibonacci Heaps 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node Operation: Insert Add new node as a heap Attach to the root linked list - O(1)
14
Fibonacci Heaps Operation: Insert Add new node as a heap Attach to the root linked list - O(1) 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node 1010 1010
15
Fibonacci Heaps Operation: Delete Minimum 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node
16
Fibonacci Heaps Operation: Delete Minimum Remove minimum node and make children roots 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 Minimum Node
17
Fibonacci Heaps Operation: Delete Minimum Remove minimum node and make children roots Union roots of same degree until all roots have different degree 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 Minimum Node
18
Fibonacci Heaps Operation: Delete Minimum Remove minimum node and make children roots Union roots of same degree until all roots have different degree 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 Minimum Node
19
Fibonacci Heaps Operation: Delete Minimum Remove minimum node and make children roots Union roots of same degree until all roots have different degree 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 Minimum Node
20
Fibonacci Heaps Operation: Delete Minimum Remove minimum node and make children roots Union roots of same degree until all roots have different degree Reset Minimum Node pointer 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 Minimum Node
21
Fibonacci Heaps Operation: Decrease Key 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node
22
Fibonacci Heaps Operation: Decrease Key Marked nodes are those having had exactly one child promoted to a root previously 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node
23
Fibonacci Heaps Operation: Decrease Key Decrease the key - if violation, cut from the tree, - promote it to a root - mark its parent if it is unmarked - if the parent had been marked cut it from its tree, and promote it to a root, and unmark it. 6 6 2 2 5 5 3 3 4 4 7 7 8 8 0 0 1 1 Minimum Node
24
Fibonacci Heaps Operation: Decrease Key Decrease the key - if violation, cut from the tree, - promote it to a root - mark its parent if it is unmarked - if the parent had been marked cut it from its tree, and promote it to a root, and unmark it. 6 6 2 2 5 5 3 3 4 4 7 7 8 8 0 0 1 1 Minimum Node
25
Fibonacci Heaps Operation: Decrease Key Decrease the key - if violation, cut from the tree, - promote it to a root - mark its parent if it is unmarked - if the parent had been marked cut it from its tree, and promote it to a root, and unmark it. - O(1) !!! 6 6 2 2 5 5 3 3 4 4 7 7 8 8 0 0 1 1 Minimum Node
26
Fibonacci Heaps Operation: Decrease Key Decrease the key - Change the Minimum Node pointer 6 6 2 2 5 5 3 3 4 4 7 7 8 8 0 0 1 1 Minimum Node
27
Fibonacci Heaps Operation: Delete Key of node to be deleted changed to minus infinity (decrease key operation) Followed by simple delete minimum 6 6 2 2 5 5 3 3 4 4 7 7 8 8 9 9 1 1 Minimum Node
28
Fibonacci Heaps Operation: Delete Key of node to be deleted changed to minus infinity (decrease key operation) Followed by simple delete minimum 6 6 2 2 5 5 3 3 4 4 7 7 8 8 -∞-∞ -∞-∞ 1 1 Minimum Node
29
Fibonacci Heaps Operation: Delete Key of node to be deleted changed to minus infinity (decrease key operation) Followed by simple delete minimum -∞-∞ -∞-∞ 2 2 5 5 3 3 4 4 7 7 8 8 6 6 1 1 Minimum Node
30
Fibonacci Heaps Operation: Delete Key of node to be deleted changed to minus infinity (decrease key operation) Followed by simple delete minimum 2 2 5 5 3 3 4 4 7 7 8 8 6 6 1 1 Minimum Node
31
Fibonacci Heaps Operation: Delete Key of node to be deleted changed to minus infinity (decrease key operation) Followed by simple delete minimum - O(log(n)) 2 2 5 5 3 3 4 4 7 7 8 8 6 6 1 1 Minimum Node
32
Fibonacci Heaps Result: Complexity of algorithms using priority queues is reduced! Example: Shortest Path – O((m+n)log(n)) with binary heap O(m +nlog(n)) with Fibonacci heap
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.