Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
ds2-notes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
datovky
ds2-notes
Commits
bb8f0814
Commit
bb8f0814
authored
6 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Preliminaries: Corrections by Vašek K.
parent
8e5c3ecf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
01-prelim/prelim.tex
+4
-4
4 additions, 4 deletions
01-prelim/prelim.tex
with
4 additions
and
4 deletions
01-prelim/prelim.tex
+
4
−
4
View file @
bb8f0814
...
...
@@ -269,7 +269,7 @@ to happen.
Now, we turn our attention to an~
$
\ell
$
-bit binary counter. Initially, all its bits are zero. Then we keep
incrementing the counter by~1. For
$
\ell
=
4
$
, we get the sequence
\|
0000|,
\|
0001|,
\|
0010|,
\|
0011|,
\|
0100|, and~so on.
Performing the increment i
t
simple: we scan the number from the right, turning
\|
1|s to
\|
0|s,
Performing the increment i
s
simple: we scan the number from the right, turning
\|
1|s to
\|
0|s,
until we hit a~
\|
0|, which we change to a~
\|
1| and stop.
A~single increment can take
$
\Theta
(
\ell
)
$
time when we go from
\|
0111|
\dots\|
1| to
\|
1000|
\dots\|
0|.
...
...
@@ -282,13 +282,13 @@ number of changes will therefore be:
$$
\sum
_{
i
=
0
}^{
\ell
-
1
}
\left\lfloor
{
n
\over
2
^
i
}
\right\rfloor
\le
\sum
_{
i
=
0
}^{
\ell
-
1
}
{
n
\over
2
^
i
}
\le
n
\cdot\sum
_{
i
=
0
}^
\ell
{
1
\over
2
^
i
}
\le
n
\cdot\sum
_{
i
=
0
}^
{
\ell
-
1
}
{
1
\over
2
^
i
}
\le
n
\cdot\sum
_{
i
=
0
}^
\infty
{
1
\over
2
^
i
}
=
2
n.
$$
However, there is an~easier and ``more economical'' approach to analysis.
Imagine that we have some
\em
{
coins
}
and each coin buys us a~constant amount of computation time,
enough to test and change one bit. We will maintain an invariant that for every~
\|
1|
bit
, we have
enough to test and change one bit. We will maintain an invariant that for every~
\|
1|, we have
one coin --- we can imagine that the coin is ``placed on the bit''.
When somebody comes and requests an increment, we ask for 2~coins. This is enough to cover the
...
...
@@ -310,7 +310,7 @@ those which spend the savings later.)
\subsection
{
The potential method
}
In the above examples, the total complexity of a~sequence of operations was much better
tha
t
the sum of their worst-case complexities. The proof usually involved increasing the
tha
n
the sum of their worst-case complexities. The proof usually involved increasing the
cost of ``easy'' operations to compensate for an occassional ``hard'' one. We are going
to generalize this approach now.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment