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
c133e455
Commit
c133e455
authored
5 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Preliminaries: There is no stretch with k=0
parent
bfe96d05
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
+3
-3
3 additions, 3 deletions
01-prelim/prelim.tex
with
3 additions
and
3 deletions
01-prelim/prelim.tex
+
3
−
3
View file @
c133e455
...
@@ -191,10 +191,10 @@ initial capacity is~1 and we always double capacity on reallocations. Then the c
...
@@ -191,10 +191,10 @@ initial capacity is~1 and we always double capacity on reallocations. Then the c
$
k
$
~reallocations will be exactly~
$
2
^
k
$
.
$
k
$
~reallocations will be exactly~
$
2
^
k
$
.
If we appended
$
n
$
~items, all reallocations together take time
If we appended
$
n
$
~items, all reallocations together take time
$
\Theta
(
2
^
0
+
2
^
1
+
\ldots
+
2
^
k
)
$
$
\Theta
(
2
^
1
+
2
^
2
+
\ldots
+
2
^
k
)
$
for~
$
k
$
such that
$
2
^{
k
-
1
}
< n
\le
2
^
k
$
(after the
$
k
$
-th reallocation the array
wa
s large enough,
for~
$
k
$
such that
$
2
^{
k
-
1
}
< n
\le
2
^
k
$
(after the
$
k
$
-th reallocation the array
i
s large enough,
but it wasn't before). This implies that
$
n
\le
2
^
k <
2
n
$
.
but it wasn't before). This implies that
$
n
\le
2
^
k <
2
n
$
.
Hence
$
2
^
0
+
\ldots
+
2
^
k
=
2
^{
k
+
1
}
-
1
\in
\Theta
(
n
)
$
.
Hence
$
2
^
1
+
\ldots
+
2
^
k
=
2
^{
k
+
1
}
-
2
\in
\Theta
(
n
)
$
.
We can conclude that while a~single append can take
$
\Theta
(
n
)
$
time, all
$
n
$
~appends also take
$
\Theta
(
n
)
$
We can conclude that while a~single append can take
$
\Theta
(
n
)
$
time, all
$
n
$
~appends also take
$
\Theta
(
n
)
$
time, as if each append took constant time only. We will say that the amortized complexity of a~single append
time, as if each append took constant time only. We will say that the amortized complexity of a~single append
...
...
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