More notes on two's-complement.
parent
cf0daeab7d
commit
a480e48e3b
|
@ -81,7 +81,9 @@
|
|||
"lattice-path-before-recurrence.png",
|
||||
"lattice-path-after-recurrence.png",
|
||||
"merge-sort.gif",
|
||||
"theta-notation.png"
|
||||
"theta-notation.png",
|
||||
"big-o-notation.png",
|
||||
"big-omega-notation.png"
|
||||
],
|
||||
"File Hashes": {
|
||||
"algorithms/index.md": "cd7c7ba91fb2f961c9f2437777e8e2ac",
|
||||
|
@ -112,7 +114,7 @@
|
|||
"posix/regexp.md": "f5fb177c7356faf1bf768023c2563c54",
|
||||
"journal/2024-02-04.md": "e2b5678fc53d7284b71ed6820c02b954",
|
||||
"gawk/regexp.md": "d9229f1eabe1b99e965eecaa03bee86c",
|
||||
"_templates/daily.md": "7866014e730e85683155207a02e367d8",
|
||||
"_templates/daily.md": "5863e4524f8d012e153918d238c611a4",
|
||||
"_journal/2024-02-05.md": "f8505abd415c50fd97c81fd6153a6d4f",
|
||||
"_journal/2024-02-06.md": "1ea415f3c3f5be17f796b9a0d4df565f",
|
||||
"_journal/2024-02-04.md": "f77a3c5f3ce7969120f226738836dc92",
|
||||
|
@ -125,7 +127,7 @@
|
|||
"algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2",
|
||||
"algorithms/loop-invariant.md": "29f9f9090a3109890d333a78acc18b50",
|
||||
"algorithms/running-time.md": "5efc0791097d2c996f931c9046c95f65",
|
||||
"algorithms/order-growth.md": "d5481b2611a39f255cbd0bb8a4120a70",
|
||||
"algorithms/order-growth.md": "f4bab009ba9a6af34b9245fe595b0a2a",
|
||||
"_journal/2024-02-08.md": "19092bdfe378f31e2774f20d6afbfbac",
|
||||
"algorithms/sorting/selection-sort.md": "fcd0dc2ebaabd0a4db1baf7e7ef9f7a9",
|
||||
"algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97",
|
||||
|
@ -173,7 +175,7 @@
|
|||
"algorithms/binary-search.md": "dbbaf8d4be7aabef1ed232c1906b4c99",
|
||||
"_journal/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048",
|
||||
"_journal/2024-02/2024-02-16.md": "e701902e369ec53098fc2deed4ec14fd",
|
||||
"binary/integer-encoding.md": "f4e553365bf596ddc7d24cfb12b63fab",
|
||||
"binary/integer-encoding.md": "81b7d429c05b5bc95c0b3d4d8d3e27f0",
|
||||
"combinatorics/index.md": "9a85e8858c50c9797243d6d01e1dcbe7",
|
||||
"_journal/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629",
|
||||
"_journal/2024-02/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048",
|
||||
|
@ -204,7 +206,7 @@
|
|||
"_journal/2024-02/2024-02-24.md": "ee92fd63ebbda5f8ffa0abd06700ead1",
|
||||
"_journal/2024-02-26.md": "ccbee662c1b2c42027bce1ed6f9a5ac4",
|
||||
"_journal/2024-02/2024-02-25.md": "426be827fe8483e4ab432304a2aa6df3",
|
||||
"_journal/2024-02-27.md": "275c99a69ac426820df1803a462154ba",
|
||||
"_journal/2024-02-27.md": "851180f1f7c1aaacd4c0b0ec2639bdf2",
|
||||
"_journal/2024-02/2024-02-26.md": "417b84be5d96f9d8adcdedca3b68b141"
|
||||
},
|
||||
"fields_dict": {
|
||||
|
|
|
@ -8,4 +8,7 @@ title: "2024-02-27"
|
|||
- [x] Go (1 Life & Death Problem)
|
||||
- [ ] Korean (Read 1 Story)
|
||||
- [ ] Interview Prep (1 Practice Problem)
|
||||
- [ ] Log Work Hours (Max 3 hours)
|
||||
- [x] Log Work Hours (Max 3 hours)
|
||||
|
||||
* Added many flashcards on $\Theta$-, $O$-, and $\Omega$-notation.
|
||||
* Yet more notes on two's-complement.
|
|
@ -155,6 +155,20 @@ Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambri
|
|||
<!--ID: 1708974221797-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
What does it mean for function $f(n)$ to be asymptotically nonnegative?
|
||||
Back: $f(n) \geq 0$ whenever $n$ is sufficiently large.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean for function $f(n)$ to be asymptotically positive?
|
||||
Back: $f(n) > 0$ whenever $n$ is sufficiently large.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1708974221871-->
|
||||
END%%
|
||||
|
||||
## $\Theta$-notation
|
||||
|
||||
![[theta-notation.png]]
|
||||
|
@ -163,7 +177,7 @@ $\Theta$-notation refers to a strict lower- and upper-bound. It is defined as se
|
|||
|
||||
%%ANKI
|
||||
Basic
|
||||
What kind of mathematical object is $\Theta(n)$?
|
||||
What kind of mathematical object is $\Theta(g(n))$?
|
||||
Back: A set.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1708974221801-->
|
||||
|
@ -250,14 +264,14 @@ END%%
|
|||
|
||||
%%ANKI
|
||||
Cloze
|
||||
Given $f(n) = \Theta(g(n))$, we say {1:$g(n)$} is an asymptotically {2:tight} bound for {1:$f(n)$}.
|
||||
Given $f(n) = \Theta(g(n))$, we say {1:$g(n)$} is an asymptotic {2:tight} bound for {1:$f(n)$}.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1708974221851-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which notation corresponds to asymptotically tight bounds?
|
||||
Which notation corresponds to asymptotic tight bounds?
|
||||
Back: $\Theta$-notation.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1708974221857-->
|
||||
|
@ -271,20 +285,6 @@ Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambri
|
|||
<!--ID: 1708974221864-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
What does it mean for function $f(n)$ to be asymptotically nonnegative?
|
||||
Back: $f(n) \geq 0$ whenever $n$ is sufficiently large.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean for function $f(n)$ to be asymptotically positive?
|
||||
Back: $f(n) > 0$ whenever $n$ is sufficiently large.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1708974221871-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What condition must $g(n)$ satisfy such that otherwise $\Theta(g(n))$ is empty?
|
||||
|
@ -336,11 +336,333 @@ END%%
|
|||
|
||||
%%ANKI
|
||||
Basic
|
||||
What values does the $y$-axis implicitly range over in the following?
|
||||
For $n < n_0$, what values does the $y$-axis take on?
|
||||
![[theta-notation.png]]
|
||||
Back: Indeterminate.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1708974221909-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
For $n \geq n_0$, what values does the $y$-axis take on?
|
||||
![[theta-notation.png]]
|
||||
Back: Nonnegative values.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1708974221909-->
|
||||
<!--ID: 1709053894064-->
|
||||
END%%
|
||||
|
||||
## $O$-notation
|
||||
|
||||
![[big-o-notation.png]]
|
||||
|
||||
$O$-notation refers to a strict upper-bound. It is defined as set $$O(g(n)) = \{ f(n) \mid \exists c, n_0 > 0, \forall n \geq n_0, 0 \leq f(n) \leq cg(n) \}$$
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What kind of mathematical object is $O(g(n))$?
|
||||
Back: A set.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894066-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers found in $O(g(n))$, what values do $c$ and $n_0$ take on?
|
||||
Back: Positive constants.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894068-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What names are usually given to the existentially quantified identifers in $O(g(n))$'s definition?
|
||||
Back: $c$ and $n_0$.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894070-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What name is usually given to the universally quantified identifer in $O(g(n))$'s definition?
|
||||
Back: $n$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894072-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
Using typical identifiers, $f(n) = O(g(n))$ satisfies {$0$} $\leq$ {$f(n)$} $\leq$ {$cg(n)$}.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894074-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers, what is the lower bound of $cg(n)$ in $O(g(n))$?
|
||||
Back: $f(n)$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894076-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers, what is the upper bound of $cg(n)$ in $O(g(n))$?
|
||||
Back: N/A
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894078-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers, what is the upper bound of $f(n)$ in $O(g(n))$?
|
||||
Back: $0$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894080-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers, what is the upper bound of $f(n)$ in $O(g(n))$?
|
||||
Back: $cg(n)$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
Given $f(n) = O(g(n))$, we say {1:$g(n)$} is an asymptotic {2:upper} bound for {1:$f(n)$}.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894084-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which notation corresponds to asymptotic upper bounds?
|
||||
Back: $O$-notation.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894088-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Every member of $O(g(n))$ is expected to be asymptotically what?
|
||||
Back: Nonnegative.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894091-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What condition must $g(n)$ satisfy such that otherwise $O(g(n))$ is empty?
|
||||
Back: $g(n)$ must be asymptotically nonnegative.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894093-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is $O(g(n))$ defined?
|
||||
Back: $\{ \exists c, n_0 > 0, \forall n \geq n_0, 0 \leq f(n) \leq cg(n) \}$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894096-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which asymptotic notation is this image demonstrating?
|
||||
![[big-o-notation.png]]
|
||||
Back: $O$-notation
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894098-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
When is it guaranteed $y$-values are nonnegative in the following?
|
||||
![[big-o-notation.png]]
|
||||
Back: When $n \geq n_0$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894100-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In set-theoretic notation, what does it mean for $\Theta$-notation to be stronger than $O$-notation?
|
||||
Back: $\Theta(g(n)) \subseteq O(g(n))$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894101-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What notation corresponds to worst-case running times?
|
||||
Back: $O$-notation
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894103-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Why does Cormen et al. say "insertion sort's running time is $O(n^2)$" is an abuse of notation?
|
||||
Back: Because technically its running time depends on the particular input of size $n$.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709053894105-->
|
||||
END%%
|
||||
|
||||
## $\Omega$-notation
|
||||
|
||||
![[big-omega-notation.png]]
|
||||
|
||||
$\Omega$-notation refers to a strict lower-bound. It is defined as set $$\Omega(g(n)) = \{ f(n) \mid \exists c, n_0 > 0, \forall n \geq n_0, 0 \leq cg(n) \leq f(n) \}$$
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What kind of mathematical object is $\Omega(g(n))$?
|
||||
Back: A set.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157375-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers found in $\Omega(g(n))$, what values do $c$ and $n_0$ take on?
|
||||
Back: Positive constants.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157377-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What names are usually given to the existentially quantified identifers in $\Omega(g(n))$'s definition?
|
||||
Back: $c$ and $n_0$.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157379-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What name is usually given to the universally quantified identifer in $\Omega(g(n))$'s definition?
|
||||
Back: $n$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157381-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
Using typical identifiers, $f(n) = \Omega(g(n))$ satisfies {$0$} $\leq$ {$cg(n)$} $\leq$ {$f(n)$}.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157383-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers, what is the lower bound of $cg(n)$ in $\Omega(g(n))$?
|
||||
Back: $0$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157384-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers, what is the upper bound of $cg(n)$ in $\Omega(g(n))$?
|
||||
Back: $f(n)$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157386-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers, what is the lower bound of $f(n)$ in $\Omega(g(n))$?
|
||||
Back: $cg(n)$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157388-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Using typical identifiers, what is the upper bound of $f(n)$ in $\Omega(g(n))$?
|
||||
Back: N/A
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157390-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
Given $f(n) = \Omega(g(n))$, we say {1:$g(n)$} is an asymptotic {2:lower} bound for {1:$f(n)$}.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157392-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which notation corresponds to asymptotic lower bounds?
|
||||
Back: $\Omega$-notation.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157393-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Every member of $\Omega(g(n))$ is expected to be asymptotically what?
|
||||
Back: Nonnegative.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157394-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What condition must $g(n)$ satisfy such that otherwise $\Omega(g(n))$ is empty?
|
||||
Back: $g(n)$ must be asymptotically nonnegative.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157396-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is $\Omega(g(n))$ defined?
|
||||
Back: $\{ \exists c, n_0 > 0, \forall n \geq n_0, 0 \leq cg(n) \leq f(n) \}$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157397-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which asymptotic notation is this image demonstrating?
|
||||
![[big-omega-notation.png]]
|
||||
Back: $\Omega$-notation
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157399-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In set-theoretic notation, what does it mean for $\Theta$-notation to be stronger than $\Omega$-notation?
|
||||
Back: $\Theta(g(n)) \subseteq \Omega(g(n))$
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157401-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What notation corresponds to best-case running times?
|
||||
Back: $\Omega$-notation
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157402-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{1:$O$}-notation is to asymptotic {2:upper}-bounds whereas {2:$\Omega$}-notation is to asymptotic {1:lower}-bounds.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157404-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What theorem relates $\Theta(g(n))$, $O(g(n))$, and $\Omega(g(n))$?
|
||||
Back: $f(n) = \Theta(g(n))$ if and only if $f(n) \in O(g(n))$ and $f(n) \in \Omega(g(n))$.
|
||||
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
|
||||
<!--ID: 1709055157406-->
|
||||
END%%
|
||||
|
||||
## References
|
||||
|
|
|
@ -530,6 +530,116 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
|||
<!--ID: 1708545383265-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Why is two's-complement named the way it is?
|
||||
Back: Because there is only one $2$ in $2^w - x$.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1709060837130-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Given two's-complement $x \geq 0$, what is the significance of $2^w - x$?
|
||||
Back: The result is the binary representation of $-x$.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1709060849456-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Let $x$ be a $w$-bit two's-complement number. What is it's complement?
|
||||
Back: The number $y$ such that $x + y = 2^w$.
|
||||
Reference: “Two’s-Complement.” In *Wikipedia*, January 9, 2024. [https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561](https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561).
|
||||
<!--ID: 1709060837141-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the precise definition of the two's-complement of a $w$-bit number?
|
||||
Back: The complement of $x$ with respect to $2^w$.
|
||||
Reference: “Two’s-Complement.” In *Wikipedia*, January 9, 2024. [https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561](https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561).
|
||||
<!--ID: 1709060837145-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
With respect to two's-complement encoding, what is the "weird number"?
|
||||
Back: $TMin$
|
||||
Reference: “Two’s-Complement.” In *Wikipedia*, January 9, 2024. [https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561](https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561).
|
||||
<!--ID: 1709060837149-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Why is $TMin$ called the "weird number"?
|
||||
Back: It is the only number that is it's own complement.
|
||||
Reference: “Two’s-Complement.” In *Wikipedia*, January 9, 2024. [https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561](https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561).
|
||||
<!--ID: 1709060837151-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is $2^w - x$ written schematically, fixed to $w = 8$ bits?
|
||||
Back:
|
||||
```
|
||||
00000000
|
||||
- x
|
||||
----------
|
||||
...
|
||||
```
|
||||
Reference: Finley, Thomas. “Two’s Complement,” April 2000. [https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html](https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html).
|
||||
<!--ID: 1709060837154-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is the following rewritten to emphasize why "two's-complement" is named the way it is?
|
||||
```
|
||||
00000000
|
||||
- 01010101
|
||||
----------
|
||||
...
|
||||
```
|
||||
Back:
|
||||
```
|
||||
100000000
|
||||
- 01010101
|
||||
-----------
|
||||
...
|
||||
```
|
||||
Reference: Finley, Thomas. “Two’s Complement,” April 2000. [https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html](https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html).
|
||||
<!--ID: 1709060837156-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is the following rewritten to emphasize two's-complement's idea of "invert and add one"?
|
||||
```
|
||||
100000000
|
||||
- 01010101
|
||||
-----------
|
||||
...
|
||||
```
|
||||
Back:
|
||||
```
|
||||
1
|
||||
+ 11111111
|
||||
- 01010101
|
||||
----------
|
||||
...
|
||||
```
|
||||
Reference: Finley, Thomas. “Two’s Complement,” April 2000. [https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html](https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html).
|
||||
<!--ID: 1709060837160-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
Subtracting $x$ from {a number of all `1` bits} is equivalent to {`~x`}.
|
||||
Reference: Finley, Thomas. “Two’s Complement,” April 2000. [https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html](https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html).
|
||||
<!--ID: 1709061032778-->
|
||||
END%%
|
||||
|
||||
## Casting
|
||||
|
||||
Most implementations of C cast an object of one type to another by simply re-interpreting the object's binary representation. This casting may happen implicitly if comparing or operating on e.g. `signed` and `unsigned` objects in the same expression. $T2U$ and $U2T$ reflect this method of casting:
|
||||
|
@ -1397,5 +1507,6 @@ END%%
|
|||
## References
|
||||
|
||||
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
* Finley, Thomas. “Two’s Complement,” April 2000. [https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html](https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html).
|
||||
* Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, *Concrete Mathematics: A Foundation for Computer Science*, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
|
||||
* “Two’s-Complement.” In *Wikipedia*, January 9, 2024. [https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561](https://en.wikipedia.org/w/index.php?title=Two%27s_complement&oldid=1194543561).
|
Loading…
Reference in New Issue