Skip to content

Commit 1bc27b6

Browse files
📚 docs(Theory): Improve wording.
1 parent 037122e commit 1bc27b6

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

doc/manual/theory.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ amortized constant time.
66
> The Fibonacci heap is of interest only if the user needs the decrease-key
77
> operation heavily. Use another data structure with better constants otherwise.
88
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).
1213

1314
## Idea
1415

@@ -24,7 +25,7 @@ We amortize the cost of each operation on a heap `H` with `n` elements
2425
using the following potential `P(H) = R(H) + 2 M(H)` where `R(H)` is the size
2526
of the root list of `H` and `M(H)` is the number of marked nodes of `H`.
2627

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,
2829
potential change, and amortized cost of the heap operations are respectively:
2930

3031
- [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
3738
our collection.
3839

3940
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) >=
4142
phi^degree(x)` (`phi` is the golden ratio `1.618...`) so that `D(H) = O(log
4243
n)`.
4344

@@ -47,17 +48,17 @@ Whenever the decision is made to add a node to a parent as a child (link),
4748
we guarantee that the child's degree is equal to the parent's degree.
4849

4950
If this child is the ith node to be added to the parent, its degree is
50-
therefore i-1.
51+
therefore `i-1`.
5152

5253
Whenever a child is removed from a parent (cut), one of two things happens:
5354

5455
1. If the parent is marked, we cut it.
5556
2. If the parent is not marked, we mark it.
5657

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`.
5859

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.
6162

6263
> Hint: `F_{k+2} = 1 + F_0 + F_1 + ... + F_k`.
6364
@@ -69,7 +70,7 @@ Hence the number of marked nodes drops proportionally to the number of cut
6970
nodes.
7071

7172
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
7374
DELETE-MIN operation but also the potential of the heap.
7475
The DELETE-MIN operation will therefore include a
7576
restructuring procedure leveraging this high potential to amortize its high
@@ -82,19 +83,19 @@ Fibonacci heap.
8283

8384
### MAKE-HEAP
8485

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.
8687
Amortized cost is therefore O(1).
8788

8889
### INSERT
8990

9091
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.
9293
The amortized cost of this operation is therefore O(1).
9394

9495
### MELD
9596

9697
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
9899
potential is zero. Amortized cost is therefore O(1).
99100

100101
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.
113114
Fortunately, as already noted, we can amortize this cost because each cut
114115
ancestors can be unmarked. Hence the number of marked nodes drops
115116
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
117118
amortized cost of `O(1)`.
118119

119120
### DELETE-MIN
120121

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
122123
root nodes. This increases the number of root nodes by the degree of the
123124
deleted node. Since the degree of a node is at most `D(H)`, the number of root nodes
124125
increases by at most `D(H)`.
@@ -131,16 +132,16 @@ node, that is `R(H) + D(H)`.
131132
To amortize this costly operation, we need to reduce the number of nodes in the
132133
root list. We do so by making sure there is at most one node of each degree in
133134
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
135136
cost of the procedure is proportional to `R(H) + D(H)` (see [below](#consolidate)),
136137
the same as updating the minimum.
137138

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
139140
> run because the list contains at most one node of each degree:
140141
> one node of degree `0`, one node of degree `1`, ..., and one node of degree
141142
> `D(H)`.
142143
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
144145
potential is at most `O(1) - R(H)`, and the amortized cost is therefore
145146
`O(D(H))`.
146147

0 commit comments

Comments
 (0)