Area and induction.
parent
7a337fd4ba
commit
aa6d8db120
|
@ -263,7 +263,7 @@
|
||||||
"algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2",
|
"algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2",
|
||||||
"algorithms/loop-invariant.md": "3b390e720f3b2a98e611b49a0bb1f5a9",
|
"algorithms/loop-invariant.md": "3b390e720f3b2a98e611b49a0bb1f5a9",
|
||||||
"algorithms/running-time.md": "5efc0791097d2c996f931c9046c95f65",
|
"algorithms/running-time.md": "5efc0791097d2c996f931c9046c95f65",
|
||||||
"algorithms/order-growth.md": "b2868f2523bb85f9e9c3fbfeb3753f0c",
|
"algorithms/order-growth.md": "1e5cbdfd9dea80ba284db3589f55e65f",
|
||||||
"_journal/2024-02-08.md": "19092bdfe378f31e2774f20d6afbfbac",
|
"_journal/2024-02-08.md": "19092bdfe378f31e2774f20d6afbfbac",
|
||||||
"algorithms/sorting/selection-sort.md": "73415c44d6f4429f43c366078fd4bf98",
|
"algorithms/sorting/selection-sort.md": "73415c44d6f4429f43c366078fd4bf98",
|
||||||
"algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97",
|
"algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97",
|
||||||
|
@ -319,7 +319,7 @@
|
||||||
"combinatorics/additive-principle.md": "d036ac511e382d5c1caca437341a5915",
|
"combinatorics/additive-principle.md": "d036ac511e382d5c1caca437341a5915",
|
||||||
"_journal/2024-02-19.md": "30d16c5373deb9cb128d2e7934ae256a",
|
"_journal/2024-02-19.md": "30d16c5373deb9cb128d2e7934ae256a",
|
||||||
"_journal/2024-02/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629",
|
"_journal/2024-02/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629",
|
||||||
"combinatorics/permutations.md": "794822b96aeeadcb31e763f52ffb7b6e",
|
"combinatorics/permutations.md": "8eeafb451a6c2a46269b19790e163ae2",
|
||||||
"combinatorics/combinations.md": "396fc32255710eaf33213efaafdc43d4",
|
"combinatorics/combinations.md": "396fc32255710eaf33213efaafdc43d4",
|
||||||
"_journal/2024-02-20.md": "b85ba0eeeb16e30a602ccefabcc9763e",
|
"_journal/2024-02-20.md": "b85ba0eeeb16e30a602ccefabcc9763e",
|
||||||
"_journal/2024-02/2024-02-19.md": "df1a9ab7ab89244021b3003c84640c78",
|
"_journal/2024-02/2024-02-19.md": "df1a9ab7ab89244021b3003c84640c78",
|
||||||
|
@ -356,7 +356,7 @@
|
||||||
"_journal/2024-03-01.md": "a532486279190b0c12954966cbf8c3fe",
|
"_journal/2024-03-01.md": "a532486279190b0c12954966cbf8c3fe",
|
||||||
"_journal/2024-02/2024-02-29.md": "0e502a2c8baf90c2f12859b03f10b5a1",
|
"_journal/2024-02/2024-02-29.md": "0e502a2c8baf90c2f12859b03f10b5a1",
|
||||||
"algebra/sequences.md": "97c217823aacf8910a1a37bde694ecfe",
|
"algebra/sequences.md": "97c217823aacf8910a1a37bde694ecfe",
|
||||||
"algebra/sequences/index.md": "208174a5a078b120fa11e296ad1d09c1",
|
"algebra/sequences/index.md": "7368b87313ea161a2655be0c39e705a3",
|
||||||
"_journal/2024-03-02.md": "08c3cae1df0079293b47e1e9556f1ce1",
|
"_journal/2024-03-02.md": "08c3cae1df0079293b47e1e9556f1ce1",
|
||||||
"_journal/2024-03/2024-03-01.md": "70da812300f284df72718dd32fc39322",
|
"_journal/2024-03/2024-03-01.md": "70da812300f284df72718dd32fc39322",
|
||||||
"algebra/sequences/triangular-numbers.md": "aafaf54e5aff9ca3c7354591fce9f833",
|
"algebra/sequences/triangular-numbers.md": "aafaf54e5aff9ca3c7354591fce9f833",
|
||||||
|
@ -492,7 +492,7 @@
|
||||||
"_journal/2024-04-30.md": "369f98b9d91de89cc1f4f581bc530c0d",
|
"_journal/2024-04-30.md": "369f98b9d91de89cc1f4f581bc530c0d",
|
||||||
"_journal/2024-04/2024-04-29.md": "b4fa2fd62e1b4fe34c1f71dc1e9f5b0b",
|
"_journal/2024-04/2024-04-29.md": "b4fa2fd62e1b4fe34c1f71dc1e9f5b0b",
|
||||||
"proofs/induction.md": "36ab5a92ae3cf9bb2def333dc41d79ff",
|
"proofs/induction.md": "36ab5a92ae3cf9bb2def333dc41d79ff",
|
||||||
"proofs/index.md": "6251417184116a217e6eef39abc12077",
|
"proofs/index.md": "561455753378c78d783b80edd9a1b4c7",
|
||||||
"_journal/2024-05-01.md": "959ff67fe3db585ba6a7b121d853bbac",
|
"_journal/2024-05-01.md": "959ff67fe3db585ba6a7b121d853bbac",
|
||||||
"_journal/2024-05-02.md": "d7d6ba7e065d807986f0bd77281c0bb1",
|
"_journal/2024-05-02.md": "d7d6ba7e065d807986f0bd77281c0bb1",
|
||||||
"data-structures/priority-queues.md": "8c5c6bf62b1a39d8f1f72b800fcb17ff",
|
"data-structures/priority-queues.md": "8c5c6bf62b1a39d8f1f72b800fcb17ff",
|
||||||
|
@ -591,12 +591,12 @@
|
||||||
"_journal/2024-06-08.md": "b20d39dab30b4e12559a831ab8d2f9b8",
|
"_journal/2024-06-08.md": "b20d39dab30b4e12559a831ab8d2f9b8",
|
||||||
"_journal/2024-06/2024-06-07.md": "c6bfc4c1e5913d23ea7828a23340e7d3",
|
"_journal/2024-06/2024-06-07.md": "c6bfc4c1e5913d23ea7828a23340e7d3",
|
||||||
"lambda-calculus/alpha-conversion.md": "6df655e60976715e5c6fbbe72b628c6d",
|
"lambda-calculus/alpha-conversion.md": "6df655e60976715e5c6fbbe72b628c6d",
|
||||||
"lambda-calculus/index.md": "aab579d6826d40d2984e5289c3f547e5",
|
"lambda-calculus/index.md": "0e47dcd2ac0c84ad4c1a5e7609dade5f",
|
||||||
"x86-64/instructions/condition-codes.md": "9c05ed99f5c96162e25f0ec4db55c656",
|
"x86-64/instructions/condition-codes.md": "9c05ed99f5c96162e25f0ec4db55c656",
|
||||||
"x86-64/instructions/logical.md": "49d40018f1fcb4ed1595d9175bbaab57",
|
"x86-64/instructions/logical.md": "49d40018f1fcb4ed1595d9175bbaab57",
|
||||||
"x86-64/instructions/arithmetic.md": "df57fdc8d260d0812464b08565ef4c51",
|
"x86-64/instructions/arithmetic.md": "df57fdc8d260d0812464b08565ef4c51",
|
||||||
"x86-64/instructions/access.md": "4589d79f9915ffeeab7b75d2208b7917",
|
"x86-64/instructions/access.md": "4589d79f9915ffeeab7b75d2208b7917",
|
||||||
"x86-64/instructions/index.md": "df78f6d1d56da054606d374ca3282bf8",
|
"x86-64/instructions/index.md": "cc5505d01d8409255fa42e87bfe15f07",
|
||||||
"_journal/2024-06-09.md": "935b3ddf65c51e680ac5c000c7e380af",
|
"_journal/2024-06-09.md": "935b3ddf65c51e680ac5c000c7e380af",
|
||||||
"_journal/2024-06/2024-06-08.md": "9e1ebc8882a395b96ca765ad5c982d68",
|
"_journal/2024-06/2024-06-08.md": "9e1ebc8882a395b96ca765ad5c982d68",
|
||||||
"_journal/2024-06-10.md": "84d27300b97c8544ab4ec68b06edd824",
|
"_journal/2024-06-10.md": "84d27300b97c8544ab4ec68b06edd824",
|
||||||
|
@ -777,7 +777,7 @@
|
||||||
"_journal/2024-08-19.md": "94836e52ec04a72d3e1dbf3854208f65",
|
"_journal/2024-08-19.md": "94836e52ec04a72d3e1dbf3854208f65",
|
||||||
"_journal/2024-08/2024-08-18.md": "6f8aec69e00401b611db2a377a3aace5",
|
"_journal/2024-08/2024-08-18.md": "6f8aec69e00401b611db2a377a3aace5",
|
||||||
"_journal/2024-08/2024-08-17.md": "b06a551560c377f61a1b39286cd43cee",
|
"_journal/2024-08/2024-08-17.md": "b06a551560c377f61a1b39286cd43cee",
|
||||||
"calculus/bounds.md": "cbae7421eaa096cd17a2f9de079f593d",
|
"calculus/bounds.md": "f89de98e888b36af3b921fc0bdb1d281",
|
||||||
"calculus/index.md": "5ee4d950533ae330ca5ef9e113fe87f3",
|
"calculus/index.md": "5ee4d950533ae330ca5ef9e113fe87f3",
|
||||||
"x86-64/instructions/conditions.md": "093cf907ccbb665961134624d19e31d3",
|
"x86-64/instructions/conditions.md": "093cf907ccbb665961134624d19e31d3",
|
||||||
"_journal/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571",
|
"_journal/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571",
|
||||||
|
@ -788,7 +788,7 @@
|
||||||
"_journal/2024-08/2024-08-21.md": "1637b8ec8475cf3eb4f41d1d86cbf5df",
|
"_journal/2024-08/2024-08-21.md": "1637b8ec8475cf3eb4f41d1d86cbf5df",
|
||||||
"_journal/2024-08/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571",
|
"_journal/2024-08/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571",
|
||||||
"_journal/2024-08-23.md": "3b2feab2cc927e267263cb1e9c173d50",
|
"_journal/2024-08-23.md": "3b2feab2cc927e267263cb1e9c173d50",
|
||||||
"set/natural-numbers.md": "0fb40d1d2f7a0f9976afbacdff1c734b",
|
"set/natural-numbers.md": "6219f07da2d79fba29bb16bcd2f48ce2",
|
||||||
"_journal/2024-08-24.md": "563fad24740e44734a87d7c3ec46cec4",
|
"_journal/2024-08-24.md": "563fad24740e44734a87d7c3ec46cec4",
|
||||||
"_journal/2024-08/2024-08-23.md": "7b5a40e83d8f07ff54cd9708017d029c",
|
"_journal/2024-08/2024-08-23.md": "7b5a40e83d8f07ff54cd9708017d029c",
|
||||||
"_journal/2024-08/2024-08-22.md": "050235d5dc772b542773743b57ce3afe",
|
"_journal/2024-08/2024-08-22.md": "050235d5dc772b542773743b57ce3afe",
|
||||||
|
@ -796,15 +796,15 @@
|
||||||
"c17/enums.md": "9414fb67aa256a0a11b7240534c67bf6",
|
"c17/enums.md": "9414fb67aa256a0a11b7240534c67bf6",
|
||||||
"c17/derived-types.md": "6fb8f23a2423f05d5bdccb6672a32e38",
|
"c17/derived-types.md": "6fb8f23a2423f05d5bdccb6672a32e38",
|
||||||
"c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875",
|
"c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875",
|
||||||
"c17/types/simple.md": "b53fd365671848f09e6a0cd46e17c1bf",
|
"c17/types/simple.md": "44d56a2998f3bba578f14672c8b0ee3c",
|
||||||
"c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d",
|
"c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d",
|
||||||
"c17/types/derived.md": "89b86ecc2440bcb1aff13e1504efd1ba",
|
"c17/types/derived.md": "ac1651775cc1a75247da176627fcf421",
|
||||||
"c17/types/basic.md": "5064e21e683c0218890058882e06b6f3",
|
"c17/types/basic.md": "5064e21e683c0218890058882e06b6f3",
|
||||||
"c17/types/index.md": "14b651bcfc8b2d62ffd200a74a9a2a6b",
|
"c17/types/index.md": "14b651bcfc8b2d62ffd200a74a9a2a6b",
|
||||||
"_journal/2024-08-25.md": "e73a8edbd027d0f1a39289540eb512f2",
|
"_journal/2024-08-25.md": "e73a8edbd027d0f1a39289540eb512f2",
|
||||||
"_journal/2024-08/2024-08-24.md": "563fad24740e44734a87d7c3ec46cec4",
|
"_journal/2024-08/2024-08-24.md": "563fad24740e44734a87d7c3ec46cec4",
|
||||||
"algebra/abs-val.md": "a47bc08db62304eb526d15ede3e300cf",
|
"algebra/abs-val.md": "a47bc08db62304eb526d15ede3e300cf",
|
||||||
"data-structures/graphs.md": "93233f0fa6980b8b311de1660de3f3e2",
|
"data-structures/graphs.md": "0f47148557943dbca068c166d3e4169a",
|
||||||
"_journal/2024-08-26.md": "5bed1b0ee34e546c31760f5a0aa5ca19",
|
"_journal/2024-08-26.md": "5bed1b0ee34e546c31760f5a0aa5ca19",
|
||||||
"_journal/2024-08/2024-08-25.md": "a3337b4658677810127350ef3e0ad146",
|
"_journal/2024-08/2024-08-25.md": "a3337b4658677810127350ef3e0ad146",
|
||||||
"_journal/2024-08-27.md": "d9ffc6ea2128ab5a86ab5f2619206736",
|
"_journal/2024-08-27.md": "d9ffc6ea2128ab5a86ab5f2619206736",
|
||||||
|
@ -917,8 +917,19 @@
|
||||||
"_journal/2024-10/2024-10-31.md": "8c5e70f566953974f252da9472e527f0",
|
"_journal/2024-10/2024-10-31.md": "8c5e70f566953974f252da9472e527f0",
|
||||||
"_journal/2024-10/2024-10-30.md": "054bdbf52843fa2445f6b9f91d5ca46e",
|
"_journal/2024-10/2024-10-30.md": "054bdbf52843fa2445f6b9f91d5ca46e",
|
||||||
"_journal/2024-10/2024-10-29.md": "432b3b073dafd54421ff6f7182ab9a58",
|
"_journal/2024-10/2024-10-29.md": "432b3b073dafd54421ff6f7182ab9a58",
|
||||||
"c17/alignment.md": "49ef4c266dbd9300211288ffa2152c7e",
|
"c17/alignment.md": "20c03c33df5feaa16c8cf6e7c67603df",
|
||||||
"_journal/2024-11-05.md": "6a599e6bc9dcd12a0940956285ae4d00"
|
"_journal/2024-11-05.md": "6a599e6bc9dcd12a0940956285ae4d00",
|
||||||
|
"_journal/2024-11-06.md": "c91de8a099cfee2514e1054400996e76",
|
||||||
|
"_journal/2024-11/2024-11-05.md": "79a1304037e18fefa135d576db040784",
|
||||||
|
"_journal/2024-11/2024-11-04.md": "69ac4ebe34ab5609a444bc9c46b55b84",
|
||||||
|
"_journal/2024-11-07.md": "01f2dec15cf5d52fa06f0a9b068c5af3",
|
||||||
|
"_journal/2024-11/2024-11-06.md": "3144245332b35aa397bc066b5bdd5dca",
|
||||||
|
"_journal/2024-11-09.md": "f34f1347cb2326fce6a505bac76d9358",
|
||||||
|
"_journal/2024-11/2024-11-08.md": "806bbade5f8339579287687f9433334e",
|
||||||
|
"_journal/2024-11/2024-11-07.md": "434ec3f15d7065ea740127aa8477dd17",
|
||||||
|
"x86-64/directives.md": "019c1c1d04efb26c3e8758aac4543cc7",
|
||||||
|
"geometry/cartesian.md": "199e29cf8debdff01d12528a50f08a92",
|
||||||
|
"geometry/index.md": "679dcd097f4bebe417828c695444c88c"
|
||||||
},
|
},
|
||||||
"fields_dict": {
|
"fields_dict": {
|
||||||
"Basic": [
|
"Basic": [
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
title: "2024-11-09"
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] Anki Flashcards
|
||||||
|
- [x] KoL
|
||||||
|
- [x] OGS
|
||||||
|
- [ ] Sheet Music (10 min.)
|
||||||
|
- [ ] Korean (Read 1 Story)
|
||||||
|
|
||||||
|
* Additional notes on alignment.
|
||||||
|
* Continued reading "Calculus, Vol. 1" by Apostol.
|
||||||
|
* Additional nodes on induction principles (weak, strong, well-ordering).
|
|
@ -2,8 +2,8 @@
|
||||||
title: "2024-11-05"
|
title: "2024-11-05"
|
||||||
---
|
---
|
||||||
|
|
||||||
- [ ] Anki Flashcards
|
- [x] Anki Flashcards
|
||||||
- [ ] KoL
|
- [x] KoL
|
||||||
- [ ] OGS
|
- [ ] OGS
|
||||||
- [ ] Sheet Music (10 min.)
|
- [ ] Sheet Music (10 min.)
|
||||||
- [ ] Korean (Read 1 Story)
|
- [ ] Korean (Read 1 Story)
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
title: "2024-11-06"
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] Anki Flashcards
|
||||||
|
- [x] KoL
|
||||||
|
- [ ] OGS
|
||||||
|
- [ ] Sheet Music (10 min.)
|
||||||
|
- [ ] Korean (Read 1 Story)
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
title: "2024-11-07"
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] Anki Flashcards
|
||||||
|
- [x] KoL
|
||||||
|
- [ ] OGS
|
||||||
|
- [ ] Sheet Music (10 min.)
|
||||||
|
- [ ] Korean (Read 1 Story)
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
title: "2024-11-08"
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] Anki Flashcards
|
||||||
|
- [x] KoL
|
||||||
|
- [x] OGS
|
||||||
|
- [ ] Sheet Music (10 min.)
|
||||||
|
- [ ] Korean (Read 1 Story)
|
|
@ -384,7 +384,7 @@ END%%
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Why isn't $a_n = 2a_{n-1} + 3a_{n-2}$ a linear homogeneous recurrence relation with constant coefficients?
|
Why isn't $a_n = 2a_{n-1} + 3a_{n-2}$ a linear homogeneous recurrence relation with constant coefficients?
|
||||||
Back: It is.
|
Back: N/A. It is.
|
||||||
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
Tags: algebra::polynomial
|
Tags: algebra::polynomial
|
||||||
<!--ID: 1714487050023-->
|
<!--ID: 1714487050023-->
|
||||||
|
|
|
@ -1211,7 +1211,7 @@ END%%
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What is the symmetric property of $\omega$-notation?
|
What is the symmetric property of $\omega$-notation?
|
||||||
Back: N/A
|
Back: N/A.
|
||||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
<!--ID: 1709752223553-->
|
<!--ID: 1709752223553-->
|
||||||
END%%
|
END%%
|
||||||
|
|
|
@ -1,15 +1,29 @@
|
||||||
---
|
---
|
||||||
title: Alignment
|
title: Alignment
|
||||||
TARGET DECK: Obsidian::STEM
|
TARGET DECK: Obsidian::STEM
|
||||||
FILE TAGS: c17 x86-64
|
FILE TAGS: c17::alignment x86-64
|
||||||
tags:
|
tags:
|
||||||
- c17
|
- c17
|
||||||
|
- x86-64
|
||||||
---
|
---
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
For a large class of modern ISAs, storage for basic C datatypes respect **self-alignmnet**. This means `char`s can start on any byte address, `short`s on any even address, 4-byte `int`s and `float`s must start on an address divisible by 4, and `double`s must start on an address divisible by 8. Likewise pointers are also self-aligned.
|
For a large class of modern ISAs, storage for basic C datatypes respect **self-alignmnet**. This means `char`s can start on any byte address, `short`s on any even address, 4-byte `int`s and `float`s must start on an address divisible by 4, and `double`s must start on an address divisible by 8. Likewise pointers are also self-aligned.
|
||||||
|
|
||||||
|
Wasted space introduced solely for alignment purposes is referred to as **slop**.
|
||||||
|
|
||||||
|
## Structures
|
||||||
|
|
||||||
|
A `struct`'s **stride address** refers to the first address following the `struct` data that has the same alignment as the `struct`. In general the compiler adds various constraints to how a `struct` is layed out:
|
||||||
|
|
||||||
|
1. The `struct`'s alignment follows that of its widest scalar member.
|
||||||
|
* This guarantees each member satisfies its own self-alignment requirement.
|
||||||
|
2. The `struct` introduces trailing padding up to its stride address.
|
||||||
|
1. This ensures each element in an array satsifies its self-alignment requirement.
|
||||||
|
|
||||||
|
The `sizeof` operator on a `struct` returns the total space used between its leading address and its stride address.
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What does self-alignment refer to?
|
What does self-alignment refer to?
|
||||||
|
@ -44,12 +58,20 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What addresses can a `double` be stored at?
|
What addresses can a `double` be stored at (outside of a `struct`)?
|
||||||
Back: Any address divisible by 8.
|
Back: Any address divisible by 8.
|
||||||
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
<!--ID: 1730831516938-->
|
<!--ID: 1730831516938-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What addresses can a `double` be stored at (inside of a `struct`)?
|
||||||
|
Back: Depending on compiler, addresses divisible by 4 or 8.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730988416659-->
|
||||||
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What addresses can a pointer be stored at?
|
What addresses can a pointer be stored at?
|
||||||
|
@ -97,6 +119,356 @@ Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed Nove
|
||||||
<!--ID: 1730831516948-->
|
<!--ID: 1730831516948-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Assume allocated order matches source order. How are the following variables aligned?
|
||||||
|
```c
|
||||||
|
char *p;
|
||||||
|
char c;
|
||||||
|
short x;
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
char *p; // 8 bytes
|
||||||
|
char c; // 1 byte
|
||||||
|
char pad[1]; // 1 byte
|
||||||
|
short x; // 2 bytes
|
||||||
|
```
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219762-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Assume allocated order matches source order. How are the following variables aligned?
|
||||||
|
```c
|
||||||
|
long x;
|
||||||
|
short c;
|
||||||
|
float f;
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
long x; // 8 bytes
|
||||||
|
short c; // 2 bytes
|
||||||
|
char pad[2]; // 2 bytes
|
||||||
|
float f; // 4 bytes
|
||||||
|
```
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219769-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Assume allocated order matches source order. What is the value of `N`?
|
||||||
|
```c
|
||||||
|
char c;
|
||||||
|
char pad1[M];
|
||||||
|
char *p;
|
||||||
|
char pad2[N];
|
||||||
|
int x;
|
||||||
|
```
|
||||||
|
Back: $0$
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219773-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Assume allocated order matches source order. What is the value of `M`?
|
||||||
|
```c
|
||||||
|
char c;
|
||||||
|
char pad1[M];
|
||||||
|
char *p;
|
||||||
|
char pad2[N];
|
||||||
|
int x;
|
||||||
|
```
|
||||||
|
Back: Between $0$ and $7$ inclusive.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219776-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider `short A[N]`. What is the internal padding of this array?
|
||||||
|
Back: $0$, i.e. `A` has no internal padding.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219780-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider `char* A[N]`. What is the internal padding of this array?
|
||||||
|
Back: $0$, i.e. `A` has no internal padding.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219784-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the alignment of a `struct` instance?
|
||||||
|
Back: That of its widest scalar member.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219788-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
*Why* is the alignment of a `struct` instance that of its widest scalar member?
|
||||||
|
Back: It is an easy way to ensure all members are self-aligned.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219792-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
*Why* does a `struct` sometimes introduce trailing padding?
|
||||||
|
Back: To ensure each element of an array of these `struct`s is self-aligned.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1731165663191-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The address of a `struct` is the same as its {first member}.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219797-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How much leading padding does a `struct` instance have?
|
||||||
|
Back: $0$
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219802-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How are members of the following `struct` aligned?
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char *p;
|
||||||
|
char c;
|
||||||
|
long x;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char *p; // 8 bytes
|
||||||
|
char c; // 1 byte
|
||||||
|
char pad[7]; // 7 bytes
|
||||||
|
long x; // 8 bytes
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219809-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How are members of the following `struct` aligned?
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char c;
|
||||||
|
char *p;
|
||||||
|
long x;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char c; // 1 byte
|
||||||
|
char pad[7]; // 7 bytes
|
||||||
|
char *p; // 8 bytes
|
||||||
|
long x; // 8 bytes
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219814-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
A `struct`'s {stride address} is {the first address following the `struct`'s data with the same alignment as the `struct`}.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219820-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the result of `sizeof(struct foo)`?
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char *p;
|
||||||
|
char c;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back: $16$
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219825-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the result of `sizeof(struct foo)`?
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
short s;
|
||||||
|
char c;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back: $4$
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219830-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What "hidden" space is returned by `sizeof` on `struct` types?
|
||||||
|
Back: Slop.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219834-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How are members of the following `struct` aligned?
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char c;
|
||||||
|
struct bar {
|
||||||
|
char *p;
|
||||||
|
short x;
|
||||||
|
} bar;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char c; // 1 byte
|
||||||
|
char pad[7]; // 7 bytes
|
||||||
|
struct bar {
|
||||||
|
char *p; // 8 bytes
|
||||||
|
short x; // 2 bytes
|
||||||
|
char pad2[6]; // 6 bytes
|
||||||
|
} bar;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219840-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How are members of the following `struct` aligned?
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char c;
|
||||||
|
struct bar {
|
||||||
|
short x;
|
||||||
|
} bar;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char c; // 1 byte
|
||||||
|
char pad[1]; // 1 byte
|
||||||
|
struct bar {
|
||||||
|
short x; // 2 bytes
|
||||||
|
} bar;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219846-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the alignment of a nested `struct`?
|
||||||
|
Back: That of its widest scalar member.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902219851-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
The `sizeof` operator on `struct`s returns the space used between what two addresses?
|
||||||
|
Back: The `struct`'s leading address and stride address.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1731165663196-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the offset of field `u` in the following?
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char u;
|
||||||
|
int v;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back: `0`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1731165663205-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the offset of field `v` in the following?
|
||||||
|
```c
|
||||||
|
struct foo {
|
||||||
|
char u;
|
||||||
|
int v;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back: `4`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1731165663209-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Unions
|
||||||
|
|
||||||
|
The `sizeof` operator on a `union` returns that of its widest member.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
The `sizeof` operator on `union`s returns what?
|
||||||
|
Back: The `sizeof` that of its widest member.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1731165663214-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the offset of field `u` in the following?
|
||||||
|
```c
|
||||||
|
union foo {
|
||||||
|
char u;
|
||||||
|
int v;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back: `0`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1731165663237-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the offset of field `v` in the following?
|
||||||
|
```c
|
||||||
|
union foo {
|
||||||
|
char u;
|
||||||
|
int v;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
Back: `0`
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1731165663242-->
|
||||||
|
END%%
|
||||||
|
|
||||||
## Bibliography
|
## Bibliography
|
||||||
|
|
||||||
|
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
* Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
* Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
|
@ -825,7 +825,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Suppose a pointer logically evaluates to `true`. Why can't we use it?
|
Suppose a pointer logically evaluates to `true`. Why might it still be unsafe to use?
|
||||||
Back: Logical evaluation can't distinguish valid pointers from indeterminate pointers.
|
Back: Logical evaluation can't distinguish valid pointers from indeterminate pointers.
|
||||||
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
<!--ID: 1730755551598-->
|
<!--ID: 1730755551598-->
|
||||||
|
@ -851,7 +851,7 @@ END%%
|
||||||
Basic
|
Basic
|
||||||
How is `r->field` equivalently written using `*`?
|
How is `r->field` equivalently written using `*`?
|
||||||
Back: `(*r).field`
|
Back: `(*r).field`
|
||||||
Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
<!--ID: 1730757470069-->
|
<!--ID: 1730757470069-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
@ -859,7 +859,7 @@ END%%
|
||||||
Basic
|
Basic
|
||||||
How is `(*r).field` more compactly written?
|
How is `(*r).field` more compactly written?
|
||||||
Back: `r->field`
|
Back: `r->field`
|
||||||
Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
<!--ID: 1730757492874-->
|
<!--ID: 1730757492874-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
@ -912,56 +912,56 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Given the following, how can we equivalent write `A[1][2]` using pointer arithmetic?
|
How do we rewrite the return statement using pointer arithmetic?
|
||||||
```c
|
```c
|
||||||
int main() {
|
int func() {
|
||||||
int A[3][4];
|
int A[3][4];
|
||||||
return 0;
|
return A[1][2];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Back: `A + 6`
|
Back: `return *(A + 6);`
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
<!--ID: 1730745799783-->
|
<!--ID: 1730745799783-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Given the following, how can we equivalent write `A[2][0]` using pointer arithmetic?
|
How do we rewrite the return statement using pointer arithmetic?
|
||||||
```c
|
```c
|
||||||
int main() {
|
int func() {
|
||||||
int A[3][4];
|
int A[3][4];
|
||||||
return 0;
|
return A[2][0];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Back: `A + 8`
|
Back: `return *(A + 8);`
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
<!--ID: 1730745799787-->
|
<!--ID: 1730745799787-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Given the following, how can we equivalent write `A[1][2]` using pointer arithmetic?
|
How do we rewrite the return statement using pointer arithmetic?
|
||||||
```c
|
```c
|
||||||
int main() {
|
int func() {
|
||||||
int A[4][3];
|
int A[4][3];
|
||||||
return 0;
|
return A[1][2];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Back: `A + 5`
|
Back: `return *(A + 5);`
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
<!--ID: 1730745799789-->
|
<!--ID: 1730745799789-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Given the following, how can we equivalent write `A[1][0]` using pointer arithmetic?
|
How do we rewrite the return statement using pointer arithmetic?
|
||||||
```c
|
```c
|
||||||
int main() {
|
int func() {
|
||||||
int A[4][3];
|
int A[4][3];
|
||||||
return 0;
|
return A[1][0];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Back: `A + 3`
|
Back: `return *(A + 3);`
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
<!--ID: 1730745799791-->
|
<!--ID: 1730745799791-->
|
||||||
END%%
|
END%%
|
||||||
|
@ -970,9 +970,7 @@ END%%
|
||||||
Basic
|
Basic
|
||||||
How is the `return` statement likely translated to x86-64?
|
How is the `return` statement likely translated to x86-64?
|
||||||
```c
|
```c
|
||||||
int* example(int *E) {
|
int* func(int *E) { return E; }
|
||||||
return E;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
Back:
|
Back:
|
||||||
```asm
|
```asm
|
||||||
|
@ -987,9 +985,7 @@ END%%
|
||||||
Basic
|
Basic
|
||||||
How is the `return` statement likely translated to x86-64?
|
How is the `return` statement likely translated to x86-64?
|
||||||
```c
|
```c
|
||||||
int example(int *E) {
|
int func(int *E) { return E[0]; }
|
||||||
return E[0];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
Back:
|
Back:
|
||||||
```asm
|
```asm
|
||||||
|
@ -1004,9 +1000,7 @@ END%%
|
||||||
Basic
|
Basic
|
||||||
How is the `return` statement likely translated to x86-64?
|
How is the `return` statement likely translated to x86-64?
|
||||||
```c
|
```c
|
||||||
int example(int *E, int i) {
|
int func(int *E, int i) { return E[i]; }
|
||||||
return E[i];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
Back:
|
Back:
|
||||||
```asm
|
```asm
|
||||||
|
@ -1021,9 +1015,7 @@ END%%
|
||||||
Basic
|
Basic
|
||||||
How is the `return` statement likely translated to x86-64?
|
How is the `return` statement likely translated to x86-64?
|
||||||
```c
|
```c
|
||||||
int example(int *E) {
|
int* func(int *E) { return &E[2]; }
|
||||||
return &E[2];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
Back:
|
Back:
|
||||||
```asm
|
```asm
|
||||||
|
|
|
@ -1360,24 +1360,40 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What type is given to enumeration constants?
|
What name is given to members of an enumeration?
|
||||||
Back: `signed int`
|
Back: An enumeration constant.
|
||||||
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
Reference: “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
|
||||||
<!--ID: 1727022810819-->
|
<!--ID: 1730902791672-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What kind of integer expressions are `enum` constants limited to?
|
What type is given to enumerated-type variables?
|
||||||
Back: Integer constant expressions.
|
Back: N/A. This is compiler dependent.
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902856916-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What type is *usually* given to enumerated-type variables?
|
||||||
|
Back: `int`
|
||||||
|
Reference: Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
|
<!--ID: 1730902856922-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What kind of integer expressions are enumeration constants limited to?
|
||||||
|
Back: Integer constant expressions with value representable as an `int`.
|
||||||
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
<!--ID: 1727022810827-->
|
<!--ID: 1727022810827-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Besides being an ICE, what other condition is expected on `enum` values?
|
Besides being an ICE, what other condition is expected on enumeration constants?
|
||||||
Back: The ICE evaluates to an integer that fits within a `signed int`.
|
Back: The ICE evaluates to an integer that fits within an `int`.
|
||||||
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
<!--ID: 1727022810833-->
|
<!--ID: 1727022810833-->
|
||||||
END%%
|
END%%
|
||||||
|
@ -1402,4 +1418,5 @@ END%%
|
||||||
|
|
||||||
* “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
|
* “ISO: Programming Languages - C,” April 12, 2011, [https://port70.net/~nsz/c/c11/n1570.pdf](https://port70.net/~nsz/c/c11/n1570.pdf).
|
||||||
* Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
* Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
|
||||||
|
* Raymond, Eric. “The Lost Art of Structure Packing.” Accessed November 4, 2024. [http://www.catb.org/esr/structure-packing/](http://www.catb.org/esr/structure-packing/).
|
||||||
* Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
|
* Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
|
||||||
|
|
|
@ -29,7 +29,7 @@ END%%
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Suppose $S \subseteq \mathbb{R}$ is bounded below by $B$. What property does set $S$ exhibit?
|
Suppose $S \subseteq \mathbb{R}$ is bounded below by $B$. What property does set $S$ exhibit?
|
||||||
Back: $S$ is nonempty..
|
Back: $S$ is nonempty.
|
||||||
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
<!--ID: 1724115335387-->
|
<!--ID: 1724115335387-->
|
||||||
END%%
|
END%%
|
||||||
|
|
|
@ -347,7 +347,7 @@ Basic
|
||||||
```
|
```
|
||||||
[ a₁ a₂ ... aⱼ | aₙ ... aᵢ ... aᵢ₊₂ aᵢ₊₁ ]
|
[ a₁ a₂ ... aⱼ | aₙ ... aᵢ ... aᵢ₊₂ aᵢ₊₁ ]
|
||||||
```
|
```
|
||||||
Back: N/A
|
Back: N/A.
|
||||||
Reference: [https://leetcode.com/problems/next-permutation/description/](https://leetcode.com/problems/next-permutation/description/)
|
Reference: [https://leetcode.com/problems/next-permutation/description/](https://leetcode.com/problems/next-permutation/description/)
|
||||||
<!--ID: 1709756610403-->
|
<!--ID: 1709756610403-->
|
||||||
END%%
|
END%%
|
||||||
|
|
|
@ -30,7 +30,7 @@ END%%
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What are the two standard ways of representing graphs in memory?
|
What are the two standard ways of representing graphs in memory?
|
||||||
Back: The adjacency-list and adjacency-matrix representation.
|
Back: The adjacency-list and adjacency-matrix representations.
|
||||||
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
Reference: Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
<!--ID: 1724614579422-->
|
<!--ID: 1724614579422-->
|
||||||
END%%
|
END%%
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
---
|
||||||
|
title: Cartesian Coordinate System
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: geometry::coordinates
|
||||||
|
tags:
|
||||||
|
- geometry
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
In plane analytic geometry, the **Cartesian coordinate system** uniquely specifies a point by a pair of real numbers called its **coordinates**. These coordinates represent signed distances to the point from two fixed perpendicular oriented lines called the **axes**. The point where the axes meet is called the **origin** and have coordinates $\langle 0, 0 \rangle$.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {$x$-coordinate} of a point is sometimes called its {abscissa).
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731184865785-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {$y$-coordinate} of a point is sometimes called its {ordinate).
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731184865791-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {origin} of a Cartesian coordinate system has coordinates $\langle 0, 0 \rangle$.
|
||||||
|
Reference: “Cartesian Coordinate System,” in _Wikipedia_, October 21, 2024, [https://en.wikipedia.org/w/index.php?title=Cartesian_coordinate_system](https://en.wikipedia.org/w/index.php?title=Cartesian_coordinate_system&oldid=1252434514).
|
||||||
|
<!--ID: 1731184876657-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider point $\langle x, y \rangle$. When does this point lie in the first quadrant?
|
||||||
|
Back: When $x > 0$ and $y > 0$.
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731184865794-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider point $\langle x, y \rangle$. When does this point lie in the second quadrant?
|
||||||
|
Back: When $x < 0$ and $y > 0$.
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731184865796-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider point $\langle x, y \rangle$. When does this point lie in the fourth quadrant?
|
||||||
|
Back: When $x > 0$ and $y < 0$.
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731184865799-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Consider point $\langle x, y \rangle$. When does this point lie in the third quadrant?
|
||||||
|
Back: When $x < 0$ and $y < 0$.
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731184865801-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
The "vertical line test" of a Cartesian coordinate system is used to determine what?
|
||||||
|
Back: Whether the tested graph depicts a function or not.
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731185808236-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In Cartesian coordinate systems, why does the vertical line test work?
|
||||||
|
Back: A function is single-valued. A vertical line that intersects a graph multiple times immediately contradicts this.
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731185808243-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Cartesian Equations
|
||||||
|
|
||||||
|
An equation that completely characters a figure within the Cartesian coordinate system is called a **Cartesian equation**.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is a Cartesian equation?
|
||||||
|
Back: An equation that completely characterizes a figure within the Cartesian coordinate system.
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731185808246-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the Cartesian equation of a circle centered around the origin with radius $r$?
|
||||||
|
Back: $x^2 + y^2 = r^2$
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731185808249-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What figure does the following Cartesian equation characterize? $x^2 + y^2 = r^2$
|
||||||
|
Back: A circle with radius $r$ centered around the origin.
|
||||||
|
Reference: Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
||||||
|
<!--ID: 1731185808252-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Bibliography
|
||||||
|
|
||||||
|
* “Cartesian Coordinate System,” in _Wikipedia_, October 21, 2024, [https://en.wikipedia.org/w/index.php?title=Cartesian_coordinate_system](https://en.wikipedia.org/w/index.php?title=Cartesian_coordinate_system&oldid=1252434514).
|
||||||
|
* Tom M. Apostol, _Calculus, Vol. 1: One-Variable Calculus, with an Introduction to Linear Algebra_, 2nd ed. (New York: Wiley, 1980).
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
title: Geometry
|
||||||
|
---
|
|
@ -488,8 +488,8 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What is wrong with asking "what is the scope of $x$ in $\lambda$-term $P$"?
|
What is wrong with asking "what is the scope of $x$ in $\lambda x. P$"?
|
||||||
Back: We should be asking about a $\lambda x$.
|
Back: We should be asking what the scope of $\lambda x$ is.
|
||||||
Reference: Hindley, J Roger, and Jonathan P Seldin. “Lambda-Calculus and Combinators, an Introduction,” n.d. [https://www.cin.ufpe.br/~djo/files/Lambda-Calculus%20and%20Combinators.pdf](https://www.cin.ufpe.br/~djo/files/Lambda-Calculus%20and%20Combinators.pdf).
|
Reference: Hindley, J Roger, and Jonathan P Seldin. “Lambda-Calculus and Combinators, an Introduction,” n.d. [https://www.cin.ufpe.br/~djo/files/Lambda-Calculus%20and%20Combinators.pdf](https://www.cin.ufpe.br/~djo/files/Lambda-Calculus%20and%20Combinators.pdf).
|
||||||
<!--ID: 1716745016007-->
|
<!--ID: 1716745016007-->
|
||||||
END%%
|
END%%
|
||||||
|
|
|
@ -295,12 +295,16 @@ END%%
|
||||||
|
|
||||||
## Induction
|
## Induction
|
||||||
|
|
||||||
Let $P(n)$ be a predicate. To prove $P(n)$ is true for all $n \geq n_0$, we prove:
|
### Weak Induction
|
||||||
|
|
||||||
* **Base case**: Prove $P(n_0)$ is true. This is usually done directly.
|
Let $P(n)$ be a predicate depending on a number $n \in \mathbb{N}$. Assume that
|
||||||
* **Inductive case**: Prove $P(k) \Rightarrow P(k + 1)$ for all $k \geq n_0$.
|
|
||||||
|
|
||||||
Within the inductive case, $P(k)$ is known as the **inductive hypothesis**.
|
* **Base case**: $P(n_0)$ is true for some $n_0 \geq 0$, and
|
||||||
|
* **Inductive case**: for all $k \geq n_0$, $P(k) \Rightarrow P(k + 1)$.
|
||||||
|
|
||||||
|
Then $P(n)$ is true for all $n \geq n_0$.
|
||||||
|
|
||||||
|
Within the inductive case, $P(k)$ is known as the **inductive hypothesis**. The formal justification of proof by induction is intimately tied to the idea of [[natural-numbers#Inductive Sets|inductive sets]].
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Cloze
|
Cloze
|
||||||
|
@ -342,7 +346,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What proposition is typically proven in the base case of an inductive proof?
|
What proposition is typically proven in the base case of a weak induction proof?
|
||||||
Back: $P(n_0)$ for some $n_0 \geq 0$.
|
Back: $P(n_0)$ for some $n_0 \geq 0$.
|
||||||
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
<!--ID: 1714530152713-->
|
<!--ID: 1714530152713-->
|
||||||
|
@ -350,7 +354,7 @@ END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What proposition is typically proven in the inductive case of an inductive proof?
|
What proposition is typically proven in the inductive case of a weak induction proof?
|
||||||
Back: $P(k) \Rightarrow P(k + 1)$ for all $k \geq n_0$.
|
Back: $P(k) \Rightarrow P(k + 1)$ for all $k \geq n_0$.
|
||||||
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
<!--ID: 1714530152718-->
|
<!--ID: 1714530152718-->
|
||||||
|
@ -396,35 +400,31 @@ END%%
|
||||||
|
|
||||||
### Strong Induction
|
### Strong Induction
|
||||||
|
|
||||||
Strong induction expands the induction hypothesis. Let $P(n)$ be a predicate. To prove $P(n)$ is true for all $n \geq n_0$, we prove:
|
Let $P(n)$ be a predicate depending on a number $n \in \mathbb{N}$. Assume that
|
||||||
|
|
||||||
* **Base case**: Prove $P(n_0)$ is true. This is usually done directly.
|
* **Base case**: $P(n_0)$ is true for some $n_0 \geq 0$, and
|
||||||
* **Inductive case**: Assume $P(k)$ is true for all $n_0 \leq k < n$. Then prove $P(n)$ is true.
|
* **Inductive case**: for all $k \geq n_0$, $P(n_0) \land P(n_0 + 1) \land \cdots \land P(k) \Rightarrow P(k + 1)$.
|
||||||
|
|
||||||
|
Then $P(n)$ is true for all $n \geq n_0$.
|
||||||
|
|
||||||
|
The formal justification of proof by induction is intimately tied to the idea of [[natural-numbers#Inductive Sets|inductive sets]] and the [[natural-numbers#Well-Ordering Principle|well-ordering principle]].
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Using typical identifiers, what is the inductive hypothesis of $P(n)$ using strong induction?
|
Using typical identifiers, what is the inductive hypothesis of $P(n)$ using strong induction?
|
||||||
Back: Assume $P(k)$ for all $k < n$.
|
Back: Assume $P(k)$ for all $n_0 \leq k < n$.
|
||||||
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
<!--ID: 1714574131949-->
|
<!--ID: 1714574131949-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
Why is strong induction considered stronger than weak induction?
|
Why makes strong induction "stronger" than weak induction?
|
||||||
Back: It can be used to solve at least the same set of problems weak induction can.
|
Back: It gives more propositions in the antecedent of the inductive case.
|
||||||
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
<!--ID: 1714574131955-->
|
<!--ID: 1714574131955-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
What negation is introduced to explain why the strong induction assumption is valid?
|
|
||||||
Back: If $P(n)$ is not true for all $n$, there exists a *first* $n_0$ for which $\neg P(n_0)$.
|
|
||||||
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
|
||||||
<!--ID: 1714574131963-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What distinguishes the base case of weak and strong induction proofs?
|
What distinguishes the base case of weak and strong induction proofs?
|
||||||
|
@ -433,6 +433,58 @@ Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n
|
||||||
<!--ID: 1714574131969-->
|
<!--ID: 1714574131969-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is the following strong induction clause rewritten to use weak induction? $$P(0) \land P(1) \land \cdots \land P(k) \Rightarrow P(k + 1)$$
|
||||||
|
Back: As $Q(k) \Rightarrow Q(k + 1)$ where $Q(n) = P(0) \land P(1) \land \cdots \land P(n)$ for all $n \in \omega$.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731203636959-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is the following weak induction clause rewritten to use strong induction? $$P(k) \Rightarrow P(k + 1)$$
|
||||||
|
Back: As $P(n_0) \land P(n_0 + 1) \land \cdots \land P(k) \Rightarrow P(k + 1)$ for some $0 \leq n_0$.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731203636963-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
### Well-Ordering Principle
|
||||||
|
|
||||||
|
This is covered [[natural-numbers#Well-Ordering Principle|here]]. It is equivalent to weak and strong induction.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What are the three most commonly used principles of induction?
|
||||||
|
Back: Weak induction, strong induction, and well-ordering.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731203636955-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Why are names "weak" and "strong" induction a misnomer?
|
||||||
|
Back: Weak and strong induction are logically equivalent.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731204485580-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is PMI an acronym for?
|
||||||
|
Back: The **p**rinciple of **m**athematical **i**nduction.
|
||||||
|
Reference: N/A.
|
||||||
|
<!--ID: 1731205303107-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is WOP an acronym for?
|
||||||
|
Back: The **w**ell-**o**rdering **p**rinciple.
|
||||||
|
Reference: N/A.
|
||||||
|
<!--ID: 1731205303114-->
|
||||||
|
END%%
|
||||||
|
|
||||||
## Bibliography
|
## Bibliography
|
||||||
|
|
||||||
* “Constructive Proof,” in _Wikipedia_, April 4, 2024, [https://en.wikipedia.org/w/index.php?title=Constructive_proof](https://en.wikipedia.org/w/index.php?title=Constructive_proof&oldid=1217198357).
|
* “Constructive Proof,” in _Wikipedia_, April 4, 2024, [https://en.wikipedia.org/w/index.php?title=Constructive_proof](https://en.wikipedia.org/w/index.php?title=Constructive_proof&oldid=1217198357).
|
||||||
|
|
|
@ -1149,6 +1149,14 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
|
||||||
<!--ID: 1729804914186-->
|
<!--ID: 1729804914186-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the order-preserving property of addition on $\omega$ in FOL?
|
||||||
|
Back: $\forall m, n, p \in \omega, m \in n \Leftrightarrow m + p \in n + p$
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731170040087-->
|
||||||
|
END%%
|
||||||
|
|
||||||
### Multiplication
|
### Multiplication
|
||||||
|
|
||||||
For each $m \in \omega$, there exists (by the recursion theorem) a unique function $M_m \colon \omega \rightarrow \omega$ such that for all $n \in \omega$, $$\begin{align*} M_m(0) & = 0, \\ M_m(n^+) & = M_m(n) + m \end{align*}$$
|
For each $m \in \omega$, there exists (by the recursion theorem) a unique function $M_m \colon \omega \rightarrow \omega$ such that for all $n \in \omega$, $$\begin{align*} M_m(0) & = 0, \\ M_m(n^+) & = M_m(n) + m \end{align*}$$
|
||||||
|
@ -1227,6 +1235,14 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
|
||||||
<!--ID: 1729804914195-->
|
<!--ID: 1729804914195-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the order-preserving property of multiplication on $\omega$ in FOL?
|
||||||
|
Back: $\forall m, n, p \in \omega, m \in n \Leftrightarrow m \cdot p^+ \in n \cdot p^+$
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731170040116-->
|
||||||
|
END%%
|
||||||
|
|
||||||
### Exponentiation
|
### Exponentiation
|
||||||
|
|
||||||
For each $m \in \omega$, there exists (by the recursion theorem) a unique function $E_m \colon \omega \rightarrow \omega$ such that for all $n \in \omega$, $$\begin{align*} E_m(0) & = 1, \\ E_m(n^+) & = E_m(n) \cdot m \end{align*}$$
|
For each $m \in \omega$, there exists (by the recursion theorem) a unique function $E_m \colon \omega \rightarrow \omega$ such that for all $n \in \omega$, $$\begin{align*} E_m(0) & = 1, \\ E_m(n^+) & = E_m(n) \cdot m \end{align*}$$
|
||||||
|
@ -1307,7 +1323,11 @@ END%%
|
||||||
|
|
||||||
## Ordering
|
## Ordering
|
||||||
|
|
||||||
For natural numbers $m$ and $n$, define $m$ to be **less than $n$** if and only if $m \in n$. It follows $m \in n \Leftrightarrow m^+ \in n^+$.
|
For natural numbers $m$ and $n$, define $m$ to be **less than $n$** if and only if $m \in n$. The following biconditionals hold true:
|
||||||
|
|
||||||
|
* $m \in n \Leftrightarrow m^+ \in n^+$
|
||||||
|
* $m \in n \Leftrightarrow m \subset n$
|
||||||
|
* $m \underline{\in} n \Leftrightarrow m \subseteq n$
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
|
@ -1363,6 +1383,38 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
|
||||||
<!--ID: 1730118488846-->
|
<!--ID: 1730118488846-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Let $m, n \in \omega$. What is the strict analog of $m \underline{\in} n \Leftrightarrow m \subseteq n$?
|
||||||
|
Back: $m \in n \Leftrightarrow m \subset n$
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731168085673-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Let $m, n \in \omega$. What is the non-strict analog of $m \in n \Leftrightarrow m \subset n$?
|
||||||
|
Back: $m \underline{\in} n \Leftrightarrow m \subseteq n$
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731168085679-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In what three ways does Enderton denote strict ordering of the natural numbers?
|
||||||
|
Back: $\in$, $\subset$, and $<$.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731170040122-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
In what three ways does Enderton denote non-strict ordering of the natural numbers?
|
||||||
|
Back: $\underline{\in}$, $\subseteq$, and $\leq$.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731170040128-->
|
||||||
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What does the trichotomy law for $\omega$ state?
|
What does the trichotomy law for $\omega$ state?
|
||||||
|
@ -1371,6 +1423,138 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
|
||||||
<!--ID: 1730118488850-->
|
<!--ID: 1730118488850-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Let $m, n \in \omega$. If $m \in n$, why is it that $m \subseteq n$?
|
||||||
|
Back: Because $n$ is a transitive set.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731168085682-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Let $m, n \in \omega$. If $m \in n$, why is it that $m \subset n$?
|
||||||
|
Back: Because $n$ is a transitive set and no natural number is a member of itself.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731168085685-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does Enterton describe is the typical way of using trichotomy in proofs?
|
||||||
|
Back: Showing that two of the three possibilities is false.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731168085688-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
### Well-Ordering Principle
|
||||||
|
|
||||||
|
Let $A$ be a nonempty subset of $\omega$. Then there is some $m \in A$ such that $m \underline{\in} n$ for all $n \in A$.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the well-ordering principle state?
|
||||||
|
Back: Every nonempty subset of $\omega$ has a least element.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731200524848-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is the well-ordering principle stated in FOL?
|
||||||
|
Back: $\forall A \subseteq \omega, A \neq \varnothing \Rightarrow \exists m \in A, \forall n \in A, m \underline{\in} n$
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731200524851-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Let $A$ be a set of $\omega$. What condition is necessary for $A$ to have a least element?
|
||||||
|
Back: $A \neq \varnothing$
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731200524854-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What principle states every nonempty subset of $\omega$ has a least element?
|
||||||
|
Back: The well-ordering principle.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731200524857-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What principle states every nonempty subset of $\omega$ has a greatest element?
|
||||||
|
Back: N/A. This is not true.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731200524861-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Suppose $A$ is a subset of $\omega$ without a least element. What can be said about $A$?
|
||||||
|
Back: $A = \varnothing$
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731200524864-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
*Why* is there no function $f \colon \omega \rightarrow \omega$ such that $f(n^+) \in f(n)$ for all $n \in \omega$?
|
||||||
|
Back: $\mathop{\text{ran}} f$ would violate the well-ordering principle.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731200524868-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
The following is a FOL representation of what principle?
|
||||||
|
$$\forall A \subseteq \omega, A \neq \varnothing \Rightarrow \exists m \in A, \forall n \in A, m \underline{\in} n$$
|
||||||
|
Back: The well-ordering principle for $\omega$.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731203636938-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How can we show set $S$ coincides with $\omega$ using the well-ordering principle?
|
||||||
|
Back: By showing $\omega - S$ has no least element.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731204485586-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
### Strong Induction Principle
|
||||||
|
|
||||||
|
Let $A$ be a subset of $\omega$ and assume that for every $n \in \omega$, $$\text{if every number less than } n \text{ is in } A, \text{then } n \in A.$$
|
||||||
|
Then $A = \omega$.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Let $A \subseteq \omega$. The strong induction principle for $\omega$ assumes what about every $n \in \omega$?
|
||||||
|
Back: If every number less than $n$ is in $A$, then $n \in A$.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731203636943-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
The following is a FOL representation of what principle?
|
||||||
|
$$[\forall A \subseteq \omega, 0 \in A \land (\forall n \in \omega, n^+ \in \omega)] \Rightarrow A = \omega$$
|
||||||
|
Back: The weak induction principle for $\omega$.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731203636947-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
The following is a FOL representation of what principle?
|
||||||
|
$$[\forall A \subseteq \omega, \forall n \in \omega, (\forall m \in n, m \in A) \Rightarrow n \in A] \Rightarrow A = \omega$$
|
||||||
|
Back: The strong induction principle for $\omega$.
|
||||||
|
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
<!--ID: 1731203636951-->
|
||||||
|
END%%
|
||||||
|
|
||||||
## Bibliography
|
## Bibliography
|
||||||
|
|
||||||
* Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
* Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
title: Directives
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: x86-64
|
||||||
|
tags:
|
||||||
|
- x86-64
|
||||||
|
---
|
||||||
|
|
||||||
|
## Directives
|
||||||
|
|
||||||
|
Assembly lines with a leading `.` are called **directives**. They are used to indicate some additional information about the program.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What term describes assembly lines with a leading `.`?
|
||||||
|
Back: Directives.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1710959313822-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Assembly directives are important for what two programs?
|
||||||
|
Back: The assembler and the linker.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1710959313826-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {`.align N`} directive ensures {data following it starts with an address that is a multiple of `N`}.
|
||||||
|
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||||
|
<!--ID: 1731165663161-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Bibliography
|
||||||
|
|
||||||
|
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
@ -44,22 +44,6 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
|
||||||
<!--ID: 1710959313818-->
|
<!--ID: 1710959313818-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
What term describes assembly lines with a leading `.`?
|
|
||||||
Back: Directives.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
<!--ID: 1710959313822-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
%%ANKI
|
|
||||||
Basic
|
|
||||||
Assembly directives are important for what two programs?
|
|
||||||
Back: The assembler and the linker.
|
|
||||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
|
||||||
<!--ID: 1710959313826-->
|
|
||||||
END%%
|
|
||||||
|
|
||||||
## Instruction Classes
|
## Instruction Classes
|
||||||
|
|
||||||
There are three types of operands:
|
There are three types of operands:
|
||||||
|
|
Loading…
Reference in New Issue