Documente Academic
Documente Profesional
Documente Cultură
Fibonacci heap.
Set of heap-ordered trees. Maintain pointer to minimum element. Set of marked nodes.
roots
heap-ordered tree
17
24
23
30
26
46
18
52
41
Heap H
35
39
44
1
Set of heap-ordered trees. Maintain pointer to minimum element. Set of marked nodes. find-min takes O(1) time
min
17
24
23
30
26
46
18
52
41
Heap H
35
39
44
2
Set of heap-ordered trees. Maintain pointer to minimum element. Set of marked nodes. use to keep heaps flat (stay tuned)
min
17
24
23
30
26
46
18
52
41
Heap H
35
marked
39
44
3
n rank(x) rank(H)
= number of nodes in heap. = number of children of node x. = max rank of any node in heap H.
trees(H) = 5
marks(H) = 3
n = 14
rank = 3
min
17
24
23
30
26
46
18
52
41
Heap H
35
marked
39
44
4
trees(H) = 5
marks(H) = 3
( H )
5 ! 23
11
min
17
24
23
30
26
46
18
52
41
Heap H
35
marked
39
44
5
reate a ne! sin"leton tree. #dd to left of min pointer. $pdate min pointer.
Insert &)
&)
min
&, ,+
&'
'
)/
*&
,) ,,
6
'.
reate a ne! sin"leton tree. #dd to left of min pointer. $pdate min pointer.
Insert &)
min
&, ,+
&'
&)
'
)/
*&
,) ,,
7
'.
reate a ne! sin"leton tree. #dd to left of min pointer. $pdate min pointer.
Insert &)
min
&, ,+
&'
&)
'
)/
*&
,) ,,
8
'.
oncatenate t!o Fibonacci heaps. 0oot lists are circular4 doubly linked lists.
min
min
&'
&,
)%
'
&)
-5
'(
&+ '*
,+
)/ '.
*&
,) ,,
-5 5
oncatenate t!o Fibonacci heaps. 0oot lists are circular4 doubly linked lists.
&'
&,
)%
'
&)
-5
'(
&+ '*
,+
)/ '.
*&
,) ,,
-5 5
10
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
min
% &, &' )% '
'(
&+
,+
)/ '.
*&
,) ,,
'*
11
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
min
current
&,
&'
)%
)/
*&
,)
'(
&+
,+
'.
,,
'*
12
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
current
&,
&'
)%
)/
*&
,)
'(
&+
,+
'.
,,
'*
13
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
current min
% &, &' )% )/ *& ,)
'(
&+
,+
'.
,,
'*
14
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
% &, &' )% )/ *& ,)
'(
&+
,+
current
'.
,,
'*
15
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
% &, &' )% )/ *& ,)
'(
&+
,+
current
'.
,,
'*
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
% &, )%
current
)/ *& ,)
'(
&+
,+
&'
'.
,,
'*
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
&, %
current
)/ *& ,)
&+
,+
)%
'(
'.
,,
'*
&'
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
%
current
)/ *& ,)
&,
)%
'(
'.
,,
&+ '*
,+
&'
19
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
%
current
)/ *& ,)
&,
)%
'(
'.
,,
&+ '*
,+
&'
20
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
% )/
current
*& ,)
&,
)%
'(
'.
,,
&+ '*
,+
&'
21
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
% )/ *&
current
,)
&,
)%
'(
'.
,,
&+ '*
,+
&'
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
% *&
current
)/
&,
)%
'(
,)
'.
&+ '*
,+
&'
,,
23
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
&
'
min
% *&
current
)/
&,
)%
'(
,)
'.
&+ '*
,+
&'
,,
24
6elete min and concatenate its children into root list. onsolidate trees so that no t!o roots ha7e same de"ree.
min
% *& )/
&,
)%
'(
,)
'.
&+ '*
,+
&'
,,
Stop.
25
1()) for decrease-key. 1(6(n)) for delete-min. 6(n) = max de"ree of any node in Fibonacci heap.
26
8ime complexity 9inomial -eap Fibonacci -eap reation 1()) 1()) Findmin 1()) 1()) Insertion 1(lo"N) 1()) mer"e 1(lo"N) 1()) 6eleteMin 1(lo"N) 1(lo"N) 6ecrease-:ey 1(lo"N) 1()) 6elete 1(lo"N) 1(lo"N)
27