Fibonacci Heap
Fibonacci Heap
Fibonacci Heap
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne
Priority Queues
Heaps
Operation
Linked List
Binary
Binomial
Fibonacci
Relaxed
make-heap
insert
log N
log N
find-min
log N
delete-min
log N
log N
log N
log N
union
log N
decrease-key
log N
log N
delete
log N
log N
log N
log N
is-empty
amortized
this time
Fibonacci Heaps
Fibonacci heap history. Fredman and Tarjan (1986)
"Lazy" unions.
min
17
30
24
26
35
23
46
marked
18
39
52
41
44
17
30
24
26
35
23
46
18
39
52
41
44
t(H) = # trees.
17
30
24
26
35
degree = 3
23
46
18
min
39
52
41
44
Insert 21
21
17
30
24
26
35
23
46
min
18
39
52
41
44
Insert 21
min
17
30
24
26
35
23
46
21
18
39
52
41
44
17
30
24
26
35
Insert 21
min
23
46
21
18
39
52
41
44
min
23
H'
30
24
26
35
46
17
min
18
39
52
21
41
44
H'
'
Change in potential = 0.
23
H'
30
24
26
35
46
17
18
39
52
21
41
44
H'
'
min
7
30
24
26
35
46
23
17
18
39
52
41
44
min
current
30
24
26
35
46
23
17
18
39
52
41
44
min
current
30
24
26
35
46
23
17
18
39
52
41
44
current
min
7
30
24
26
35
46
23
17
18
39
52
41
44
min
7
30
26
35
24
23
46
current
17
18
39
52
41
44
min
7
30
24
26
46
23
17
18
current
52
39
35
41
44
current
min
7
30
26
24
17
18
46
23
39
52
35
41
44
current
min
24
26
35
46
17
18
30
39
52
23
41
44
current
min
26
35
24
17
46
23
18
30
39
52
41
44
current
min
26
35
24
17
46
23
18
30
39
52
41
44
current
min
26
35
24
17
46
23
18
30
39
52
41
44
current
min
26
24
17
46
23
18
30
39
52
41
44
current
min
7
26
35
24
17
46
23
30
52
18
41
44
39
current
min
7
26
35
24
17
46
23
30
52
18
41
44
39
min
7
26
24
17
46
23
52
41
30
44
Stop.
35
18
39
O(D(n)) work adding min's children into root list and updating min.
at most D(n) children of min node
O(D(n) + t(H)) work consolidating trees.
work is proportional to size of root list since number of roots
decreases by one after each merging
D(n) + t(H) - 1 root nodes at beginning of consolidation
min
7
35
24
17
26
46
45
30
88
72
23
21
18
38
39
41
52
Decrease 46 to 45.
min
7
35
24
17
26
45
15
30
88
72
23
21
18
38
39
41
52
Decrease 45 to 15.
min
7
35
24
17
26
15
30
88
72
23
21
18
38
39
41
52
Decrease 45 to 15.
min
15
72
24
26
35
88
17
30
23
21
18
38
39
41
52
Decrease 45 to 15.
72
24
26
35
5
88
17
30
23
21
18
38
39
41
52
Decrease 35 to 5.
72
parent marked
24
26
88
17
30
23
21
18
38
39
41
52
Decrease 35 to 5.
72
26
88
24
17
parent marked30
23
21
18
38
39
41
52
Decrease 35 to 5.
72
26
88
24
17
30
23
21
18
38
39
41
52
Decrease 35 to 5.
t(H)
= # trees in heap H.
O(1) time for each of c cascading cuts, plus reinserting in root list.
t(H') = t(H) + c
m(H') m(H) - c + 2
each cascading cut unmarks a node
last cascading cut could potentially mark a node
c + 2(-c + 2) = 4 - c.
Decrease key of x to -.
if i 1
0
i 2 if i 1
degree ( yi )
Proof.
Thus, degree(yi) = i - 1 or i - 2
sk
size ( x*)
k
2 size ( yi )
i 2
k
2 sdeg[ y ]
i 2
k
2 si 2
i 2
k 2
2 si
i 0
Fibonacci Facts
Definition. The Fibonacci sequence is:
1, 2, 3, 5, 8, 13, 21, . . .
Slightly nonstandard definition.
Fk 2
F F
k -2
k -1
if k 0
if k 1
if k 2
Fact F2.
k 2
For k 2, Fk 2 Fi
i 0
sk
size ( x*)
k
2 size ( yi )
Consequence. sk Fk
k.
i 2
k
2 sdeg[ y ]
i 2
k
2 si 2
i 2
k 2
2 si
i 0
Golden Ratio
Definition. The Fibonacci sequence is: 1, 2, 3, 5, 8, 13, 21, . . .
Definition. The golden ratio = (1 + 5) / 2 = 1.618
Divide a rectangle into a square and smaller rectangle such that the
smaller rectangle has the same ratio as original one.
Fibonacci Facts
Pinecone
Cauliflower
Fibonacci Proofs
Fact F1. Fk k.
Proof. (by induction on k)
Fk 2
Base cases:
F0 = 1, F1 = 2 .
Fk Fk 1
k k 1
k (1 )
k ( 2 )
k 2
Inductive hypotheses:
Fk k and Fk+1 k+1
2 = + 1
k 2
Base cases:
F2 = 3, F3 = 5
Fk 2
Fk Fk 1
k 2
2 Fi Fk 1
Inductive hypotheses:
k 2
Fk 2 Fi
i 0
i 0
k
2 Fk
i 0
On Complicated Algorithms
"Once you succeed in writing the programs for [these] complicated
algorithms, they usually run extremely fast. The computer doesn't
need to understand the algorithm, its task is only to run the
programs."
R. E. Tarjan