Fibonacci Heaps

farseen 2,277 views 49 slides Nov 06, 2015
Slide 1
Slide 1 of 49
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49

About This Presentation

presentation about Fibonacci heaps and its operations


Slide Content

Fibonacci Heaps 1 Created by: Naseeba P P

What is a Fibonacci Heap? Heap ordered Trees. Rooted , but unordered. Children of a node are linked together in a Circular, doubly linked List. Collection of unordered Binomial Trees. Support Mergeable heap operations such as Insert, Minimum, Extract Min, and Union in constant time O(1). Desirable when the number of Extract Min and Delete operations are small relative to the number of other operations. 2

Cont.. 3 Node Pointers - left [x] - right [x] - degree [x] - number of children in the child list of x - - mark [x]

Fibonacci Heap Operations Insertion Linking operation Extract Minimum Node Decrease key Delete 4

I nsert Create a new singleton tree. 5

Cont.. Add to root list; update min pointer (if necessary). Increment the total number of nodes in the Heap, n[H]. 6

Insert: Algorithm 7

Insert Analysis Actual cost. O(1) Change in potential. +1 Amortized cost. O(1) P otential of heap H  (H)  =  trees(H) + 2  marks(H) 8

Union Combine two Fibonacci heaps 9

Cont.. 10

Union: Algorithm 11

Union Analysis Potential function Actual cost. O(1) Change in potential. Amortized cost. O(1) 12  ( H )  =  trees ( H ) + 2  marks ( H )

Delete or Extract Min Delete minimum 13

Cont.. Meld its children into root list. Update minimum. 14

Cont.. Consolidate trees so that no two roots have same rank. 15

Cont.. current 16

Cont.. current 17

Cont.. current 18

Cont.. current 19

Cont.. current Link 23 into 17 20

Cont.. Link 17 into 7 21

Cont.. Link 24 into 7 22

Cont.. current 23

Cont.. current 24

Cont.. current 25

Cont.. current Link 41 into 18 26

Cont.. 27

Cont.. 28

Cont.. Stop 29

Delete Min: Algorithm 30

Cont.. 31

Cont.. 32

Delete Min Analysis Delete min. Actual cost. O(rank(H)) + O(trees(H)) O(rank(H)) to meld min's children into root list. O(rank(H)) + O(trees(H)) to update min. O(rank(H)) + O(trees(H)) to consolidate trees. Change in potential. O(rank(H)) - trees(H) trees(H' )  rank(H) + 1 since no two trees have same rank. ( H )  rank(H) + 1 - trees(H). Amortized cost. O(rank(H))  ( H )  =  trees ( H ) + 2  marks ( H ) Potential function 33

Decrease Key Intuition for deceasing the key of node x. If heap-order is not violated, just decrease the key of x. Otherwise, cut tree rooted at x and meld into root list. To keep trees flat: as soon as a node has its second child cut, cut it off and meld into root list (and unmark it). 34

Cont.. Case 1. [heap order not violated] Decrease key of x. Change heap min pointer (if necessary). 35

Cont.. Case 2a. [heap order violated] Decrease key of x. 36

Cont.. Cut tree rooted at x, meld into root list, and unmark. 37

Cont.. If parent p of x is unmarked (hasn't yet lost a child), mark it. 38

Cont.. Case 2b. [heap order violated] Decrease key of x. 39

Cont.. Cut tree rooted at x, meld into root list, and unmark. 40

Cont.. If parent p of x is marked 41

Cont.. Cut p, meld into root list, and unmark 42

Cont.. Do so recursively for all ancestors that lose a second child. 43

Cont.. Do so recursively for all ancestors that lose a second child. 44

Decrease key: Algorithm 45

Cont.. 46

Decrease Key Analysis Decrease-key. Actual cost. O(c) O(1) time for changing the key. O(1) time for each of c cuts, plus melding into root list. Change in potential. O(1) - c trees(H') = trees(H) + c. marks(H')  marks(H) - c + 2.   c + 2  (- c + 2) = 4 - c . Amortized cost. O(1 )  ( H )  =  trees ( H ) + 2  marks ( H ) Potential function 47

Delete Delete node x. decrease-key of x to - . delete-min element in heap. Amortized cost. O(rank(H)) O(1) amortized for decrease-key. O(rank(H)) amortized for delete-min. 48

THANK YOU 49
Tags