@@ -6,9 +6,10 @@ amortized constant time.
6
6
> The Fibonacci heap is of interest only if the user needs the decrease-key
7
7
> operation heavily. Use another data structure with better constants otherwise.
8
8
9
- Recall that for any sequence of operations, the sum of the real costs of the
10
- operations is upper bounded by the sum of the amortized costs of the
11
- operations (as long as our potential stays non-negative).
9
+ Recall that, in an amortized analysis, for any sequence of operations, the sum
10
+ of the actual total cost of the performed operations is upper bounded by the
11
+ sum of the amortized costs of these operations (as long as the potential
12
+ defined for the analysis is non-negative at all times).
12
13
13
14
## Idea
14
15
@@ -24,7 +25,7 @@ We amortize the cost of each operation on a heap `H` with `n` elements
24
25
using the following potential ` P(H) = R(H) + 2 M(H) ` where ` R(H) ` is the size
25
26
of the root list of ` H ` and ` M(H) ` is the number of marked nodes of ` H ` .
26
27
27
- Let ` D(H) ` denote the maximum degree of a node in ` H ` , then the real cost,
28
+ Let ` D(H) ` denote the maximum degree of a node in ` H ` , then the actual cost,
28
29
potential change, and amortized cost of the heap operations are respectively:
29
30
30
31
- [ MAKE-HEAP] ( #make-heap ) : ` O(1) ` , ` 0 ` , ` O(1) ` .
@@ -37,7 +38,7 @@ Where `c` in DECREASE-KEY can be has large as the height of the tallest tree in
37
38
our collection.
38
39
39
40
To obtain a good bound on the amortized cost of the DELETE-MIN
40
- operation we make sure each subtree of a node ` x ` has `size(x) >=
41
+ operation we make sure each subtree rooted at a node ` x ` has `size(x) >=
41
42
phi^degree(x)` ( ` phi` is the golden ratio ` 1.618...` ) so that ` D(H) = O(log
42
43
n)`.
43
44
@@ -47,17 +48,17 @@ Whenever the decision is made to add a node to a parent as a child (link),
47
48
we guarantee that the child's degree is equal to the parent's degree.
48
49
49
50
If this child is the ith node to be added to the parent, its degree is
50
- therefore i-1.
51
+ therefore ` i-1 ` .
51
52
52
53
Whenever a child is removed from a parent (cut), one of two things happens:
53
54
54
55
1 . If the parent is marked, we cut it.
55
56
2 . If the parent is not marked, we mark it.
56
57
57
- This guarantees that the degree of the ith child of a parent is at least i - 2.
58
+ This guarantees that the degree of the ith child of a parent is at least ` i - 2 ` .
58
59
59
- It can then be proven that the size of any node x of degree k is
60
- ` size(x) >= F_{k+2} >= phi^k ` where ` F_i ` is the ith Fibonacci number.
60
+ It can then be proven that the size of the subtree rooted at a node ` x ` of degree
61
+ ` k ` is ` size(x) >= F_{k+2} >= phi^k ` where ` F_i ` is the ith Fibonacci number.
61
62
62
63
> Hint: ` F_{k+2} = 1 + F_0 + F_1 + ... + F_k ` .
63
64
@@ -69,7 +70,7 @@ Hence the number of marked nodes drops proportionally to the number of cut
69
70
nodes.
70
71
71
72
The number of root nodes may grow arbitrarily large through INSERT, MERGE, and
72
- DECREASE-KEY operations. This will increase the real cost of the next
73
+ DECREASE-KEY operations. This will increase the actual cost of the next
73
74
DELETE-MIN operation but also the potential of the heap.
74
75
The DELETE-MIN operation will therefore include a
75
76
restructuring procedure leveraging this high potential to amortize its high
@@ -82,19 +83,19 @@ Fibonacci heap.
82
83
83
84
### MAKE-HEAP
84
85
85
- Initialize an empty heap. Real cost is O(1) and initial potential is zero.
86
+ Initialize an empty heap. Actual cost is O(1) and initial potential is zero.
86
87
Amortized cost is therefore O(1).
87
88
88
89
### INSERT
89
90
90
91
Add new node as a root node. Update minimum with a single comparison.
91
- The real cost of this operation is constant. The change of potential is one.
92
+ The actual cost of this operation is constant. The change of potential is one.
92
93
The amortized cost of this operation is therefore O(1).
93
94
94
95
### MELD
95
96
96
97
Concatenate heaps root lists in constant time. Update minimum with a single
97
- comparison. The real cost of this operation is constant and the change of
98
+ comparison. The actual cost of this operation is constant and the change of
98
99
potential is zero. Amortized cost is therefore O(1).
99
100
100
101
NB: Insert is meld where one of the heaps contains a single node.
@@ -113,12 +114,12 @@ ancestor is reached to guarantee the small degree property of the nodes.
113
114
Fortunately, as already noted, we can amortize this cost because each cut
114
115
ancestors can be unmarked. Hence the number of marked nodes drops
115
116
proportionally to the number of cut nodes. The exact computation gives, for ` c `
116
- cut nodes, a real cost of ` O(c) ` , a change of potential of ` 2-c ` , and an
117
+ cut nodes, a actual cost of ` O(c) ` , a change of potential of ` 2-c ` , and an
117
118
amortized cost of ` O(1) ` .
118
119
119
120
### DELETE-MIN
120
121
121
- Minimum node is a root node. We can add all children of the deleted node as
122
+ The minimum node is a root node. We can add all children of the deleted node as
122
123
root nodes. This increases the number of root nodes by the degree of the
123
124
deleted node. Since the degree of a node is at most ` D(H) ` , the number of root nodes
124
125
increases by at most ` D(H) ` .
@@ -131,16 +132,16 @@ node, that is `R(H) + D(H)`.
131
132
To amortize this costly operation, we need to reduce the number of nodes in the
132
133
root list. We do so by making sure there is at most one node of each degree in
133
134
the root list. We call this procedure CONSOLIDATE. Once that procedure is
134
- finished, there are at most ` D(H) + 1 ` nodes left in the root list. The real
135
+ finished, there are at most ` D(H) + 1 ` nodes left in the root list. The actual
135
136
cost of the procedure is proportional to ` R(H) + D(H) ` (see [ below] ( #consolidate ) ),
136
137
the same as updating the minimum.
137
138
138
- > There are at most ` D(H) + 1 ` left in the root list after this procedure is
139
+ > There are at most ` D(H) + 1 ` nodes left in the root list after this procedure is
139
140
> run because the list contains at most one node of each degree:
140
141
> one node of degree ` 0 ` , one node of degree ` 1 ` , ..., and one node of degree
141
142
> ` D(H) ` .
142
143
143
- To sum up, the real cost of DELETE-MIN is ` O(R(H)+D(H)) ` , the change of
144
+ To sum up, the actual cost of DELETE-MIN is ` O(R(H)+D(H)) ` , the change of
144
145
potential is at most ` O(1) - R(H) ` , and the amortized cost is therefore
145
146
` O(D(H)) ` .
146
147
0 commit comments