Daily notes and flashcard changes.

main
Joshua Potter 2024-10-07 07:42:56 -06:00
parent f2781330db
commit 926f709811
22 changed files with 765 additions and 47 deletions

View File

@ -206,7 +206,15 @@
"graph-non-subgraph.png", "graph-non-subgraph.png",
"bfs.gif", "bfs.gif",
"closed-addressing.png", "closed-addressing.png",
"open-addressing.png" "open-addressing.png",
"theta-notation.png",
"big-o-notation.png",
"big-omega-notation.png",
"b-tree-full-node.png",
"b-tree-split-node.png",
"b-tree-initial.png",
"b-tree-inserted-b.png",
"b-tree-inserted-q.png"
], ],
"File Hashes": { "File Hashes": {
"algorithms/index.md": "3ac071354e55242919cc574eb43de6f8", "algorithms/index.md": "3ac071354e55242919cc574eb43de6f8",
@ -250,7 +258,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": "764610efa15de0be6d4092127b61440c", "algorithms/order-growth.md": "b2868f2523bb85f9e9c3fbfeb3753f0c",
"_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",
@ -318,7 +326,7 @@
"_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7", "_journal/2024-02/2024-02-21.md": "f423137ae550eb958378750d1f5e98c7",
"_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd", "_journal/2024-02-23.md": "219ce9ad15a8733edd476c97628b71fd",
"_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b", "_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b",
"c17/strings.md": "2da50edd26eae35c81f70e65bbd12d49", "c17/strings.md": "84c9b2b98d58bad9f057596a78901b13",
"c17/index.md": "02722edf46dd45f732996eaa1980944f", "c17/index.md": "02722edf46dd45f732996eaa1980944f",
"c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500", "c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500",
"c17/declarations.md": "2d7877915bf8a2772d1e4de636ba52a5", "c17/declarations.md": "2d7877915bf8a2772d1e4de636ba52a5",
@ -386,7 +394,7 @@
"_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f", "_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f",
"_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b", "_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b",
"set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53", "set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53",
"set/index.md": "9ac07f7fc1fadf1b42278df90b464adb", "set/index.md": "05a73d62902e3eecec7ce7b902027590",
"set/graphs.md": "a56f867f51e69cb7438bbdf6215fca36", "set/graphs.md": "a56f867f51e69cb7438bbdf6215fca36",
"_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb", "_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb",
"_journal/2024-03/2024-03-18.md": "2c711c50247a9880f7ed0d33b16e1101", "_journal/2024-03/2024-03-18.md": "2c711c50247a9880f7ed0d33b16e1101",
@ -581,7 +589,7 @@
"lambda-calculus/index.md": "aab579d6826d40d2984e5289c3f547e5", "lambda-calculus/index.md": "aab579d6826d40d2984e5289c3f547e5",
"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": "a6e6ef93b7c37b058cffc6dff5786ab7", "x86-64/instructions/arithmetic.md": "df57fdc8d260d0812464b08565ef4c51",
"x86-64/instructions/access.md": "3efe399b89b947ab280dc1e045675390", "x86-64/instructions/access.md": "3efe399b89b947ab280dc1e045675390",
"x86-64/instructions/index.md": "72c19067e938ab39ea51d25d6ac2bad9", "x86-64/instructions/index.md": "72c19067e938ab39ea51d25d6ac2bad9",
"_journal/2024-06-09.md": "935b3ddf65c51e680ac5c000c7e380af", "_journal/2024-06-09.md": "935b3ddf65c51e680ac5c000c7e380af",
@ -686,8 +694,8 @@
"_journal/2024-07/2024-07-20.md": "d8685729effc374e4ece1e618c2fdad3", "_journal/2024-07/2024-07-20.md": "d8685729effc374e4ece1e618c2fdad3",
"logic/classical/index.md": "ee0a4b2bfcfa2cab0880db449cb62df1", "logic/classical/index.md": "ee0a4b2bfcfa2cab0880db449cb62df1",
"logic/classical/truth-tables.md": "b739e2824a4a5c26ac446e7c15ce02aa", "logic/classical/truth-tables.md": "b739e2824a4a5c26ac446e7c15ce02aa",
"formal-system/proof-system/index.md": "800e93b72a9852ea4823ab0a40854bba", "formal-system/proof-system/index.md": "c0358072f83d73989f4a7e98dbc0dc32",
"formal-system/proof-system/equiv-trans.md": "fd837abff3eaac4f4c949a1bb69127c5", "formal-system/proof-system/equiv-trans.md": "72d96306d5bc818e67b5a6aa777b7036",
"formal-system/logical-system/index.md": "708bb1547e7343c236068c18da3f5dc0", "formal-system/logical-system/index.md": "708bb1547e7343c236068c18da3f5dc0",
"formal-system/logical-system/pred-logic.md": "4559020fde708b9d0184d9fd56559c98", "formal-system/logical-system/pred-logic.md": "4559020fde708b9d0184d9fd56559c98",
"formal-system/logical-system/prop-logic.md": "b61ce051795d5a951c763b928ec5cea8", "formal-system/logical-system/prop-logic.md": "b61ce051795d5a951c763b928ec5cea8",
@ -740,7 +748,7 @@
"_journal/2024-08/2024-08-07.md": "119c052f4109a3e098d825b771af89de", "_journal/2024-08/2024-08-07.md": "119c052f4109a3e098d825b771af89de",
"_journal/2024-08-09.md": "2ce3e0c468f51750d8ad86a19bcc3264", "_journal/2024-08-09.md": "2ce3e0c468f51750d8ad86a19bcc3264",
"_journal/2024-08/2024-08-08.md": "b8211a4c576ff594217e2e9cae9396c0", "_journal/2024-08/2024-08-08.md": "b8211a4c576ff594217e2e9cae9396c0",
"data-structures/b-tree.md": "32673aceb58a3605e0386f490a7aaefc", "data-structures/b-tree.md": "011f11424c9892219dcaa66de72f3f18",
"data-structures/binary-tree.md": "67b0b5b9688faa205983993fe507079a", "data-structures/binary-tree.md": "67b0b5b9688faa205983993fe507079a",
"_journal/2024-08-10.md": "08e7ea4a78c46645b93ec51e2372d04f", "_journal/2024-08-10.md": "08e7ea4a78c46645b93ec51e2372d04f",
"_journal/2024-08/2024-08-09.md": "2ce3e0c468f51750d8ad86a19bcc3264", "_journal/2024-08/2024-08-09.md": "2ce3e0c468f51750d8ad86a19bcc3264",
@ -758,7 +766,7 @@
"_journal/2024-08/2024-08-15.md": "7c3a96a25643b62b0064bf32cb17d92f", "_journal/2024-08/2024-08-15.md": "7c3a96a25643b62b0064bf32cb17d92f",
"_journal/2024-08-17.md": "b06a551560c377f61a1b39286cd43cee", "_journal/2024-08-17.md": "b06a551560c377f61a1b39286cd43cee",
"_journal/2024-08/2024-08-16.md": "da1127a1985074a3930b4c3512344025", "_journal/2024-08/2024-08-16.md": "da1127a1985074a3930b4c3512344025",
"set/order.md": "6c0e404f6d228919b2a7d741476ebeca", "set/order.md": "0bfff1dbd51bc49a9c1df5766ff01044",
"_journal/2024-08-18.md": "6f8aec69e00401b611db2a377a3aace5", "_journal/2024-08-18.md": "6f8aec69e00401b611db2a377a3aace5",
"ontology/philosophy/properties.md": "41b32249d3e4c23d73ddb3a417d65a4c", "ontology/philosophy/properties.md": "41b32249d3e4c23d73ddb3a417d65a4c",
"_journal/2024-08-19.md": "94836e52ec04a72d3e1dbf3854208f65", "_journal/2024-08-19.md": "94836e52ec04a72d3e1dbf3854208f65",
@ -766,7 +774,7 @@
"_journal/2024-08/2024-08-17.md": "b06a551560c377f61a1b39286cd43cee", "_journal/2024-08/2024-08-17.md": "b06a551560c377f61a1b39286cd43cee",
"calculus/bounds.md": "cbae7421eaa096cd17a2f9de079f593d", "calculus/bounds.md": "cbae7421eaa096cd17a2f9de079f593d",
"calculus/index.md": "5ee4d950533ae330ca5ef9e113fe87f3", "calculus/index.md": "5ee4d950533ae330ca5ef9e113fe87f3",
"x86-64/instructions/conditions.md": "60f1b9a7779bf4e5a817699b60e727eb", "x86-64/instructions/conditions.md": "093cf907ccbb665961134624d19e31d3",
"_journal/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571", "_journal/2024-08-20.md": "e8bec308d1b29e411c6799ace7ef6571",
"algebra/arch-prop.md": "bca3724ef5aae3f7f20907108087af47", "algebra/arch-prop.md": "bca3724ef5aae3f7f20907108087af47",
"_journal/2024-08/2024-08-19.md": "94836e52ec04a72d3e1dbf3854208f65", "_journal/2024-08/2024-08-19.md": "94836e52ec04a72d3e1dbf3854208f65",
@ -775,7 +783,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": "52f33a992318b164829eaeab07f1c58c", "set/natural-numbers.md": "72b6ffb986e47609bf8c41d6711d4372",
"_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",
@ -783,9 +791,9 @@
"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": "78ad78da8382f8af6418b519409b927d", "c17/types/simple.md": "502c7a742e8516057f820c75cc7a096e",
"c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d", "c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d",
"c17/types/derived.md": "aff0d2b6d218fb67af3cc92ead924de3", "c17/types/derived.md": "4bc5b8d8a8d24a9048f2a0e1c96af8ab",
"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",
@ -849,7 +857,18 @@
"_journal/2024-09/2024-09-27.md": "d788fa04c029009f42387317c549d93e", "_journal/2024-09/2024-09-27.md": "d788fa04c029009f42387317c549d93e",
"encoding/binary.md": "0b9beb6913906aa2523d8ab193c67f67", "encoding/binary.md": "0b9beb6913906aa2523d8ab193c67f67",
"_journal/2024-09-29.md": "232733c9ad7ebd89e8834cd61e1536d7", "_journal/2024-09-29.md": "232733c9ad7ebd89e8834cd61e1536d7",
"_journal/2024-09/2024-09-28.md": "1b47792313acf09b1ae768d5918df703" "_journal/2024-09/2024-09-28.md": "1b47792313acf09b1ae768d5918df703",
"_journal/2024-10-01.md": "2547ea281e11e2bc728d2b21787f1270",
"_journal/2024-09/2024-09-30.md": "8a423586bb9f6174dff50b075d64f4e2",
"_journal/2024-09/2024-09-29.md": "95b8f280df50dc190f60a3cd8001fb8c",
"_journal/2024-10-02.md": "cee43224994fadd51be2156f4b93f2f0",
"_journal/2024-10/2024-10-01.md": "fe3c4efd15f2dbb58bf43182d230b385",
"_journal/2024-10-03.md": "08817e93e9fea465d74c385721ee7706",
"_journal/2024-10/2024-10-02.md": "cee43224994fadd51be2156f4b93f2f0",
"_journal/2024-10-06.md": "851efa5156caadd79c898538a153c0dd",
"_journal/2024-10/2024-10-05.md": "88b4c0155583394ece5f16c01e051019",
"_journal/2024-10/2024-10-04.md": "6836a9c6eff8b5723ef474f4f4c298ed",
"_journal/2024-10/2024-10-03.md": "3f8c9a05e129ac698bad77873f114fe0"
}, },
"fields_dict": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -0,0 +1,9 @@
---
title: "2024-09-30"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)

View File

@ -0,0 +1,9 @@
---
title: "2024-10-07"
---
- [ ] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)

View File

@ -0,0 +1,9 @@
---
title: "2024-10-01"
---
- [x] Anki Flashcards
- [x] KoL
- [ ] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)

View File

@ -0,0 +1,11 @@
---
title: "2024-10-02"
---
- [x] Anki Flashcards
- [x] KoL
- [ ] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* Notes on jump tables.

View File

@ -0,0 +1,11 @@
---
title: "2024-10-03"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* Begin adding notes on C [[derived|derived types]].

View File

@ -0,0 +1,11 @@
---
title: "2024-10-04"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* Finished [Query Execution](https://15445.courses.cs.cmu.edu/fall2022/files/hw3-clean.pdf) database homework.

View File

@ -0,0 +1,9 @@
---
title: "2024-10-05"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)

View File

@ -0,0 +1,11 @@
---
title: "2024-10-06"
---
- [x] Anki Flashcards
- [x] KoL
- [ ] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* Added notes on array parameter declarations.

View File

@ -792,7 +792,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What is the reflexive property of $o$-notation? What is the reflexive property of $o$-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: 1709752223399--> <!--ID: 1709752223399-->
END%% END%%

View File

@ -42,6 +42,35 @@ Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Program
<!--ID: 1707758281270--> <!--ID: 1707758281270-->
END%% END%%
%%ANKI
Basic
What kind of array has literals?
Back: Strings.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147668-->
END%%
%%ANKI
Cloze
A {string} is a {`NUL`}-terminated array of {`char`}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147671-->
END%%
%%ANKI
Cloze
`<string.h>` uses prefix {`mem`} to refer to {array} arguments.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147673-->
END%%
%%ANKI
Cloze
`<string.h>` uses prefix {`str`} to refer to {string} arguments.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147676-->
END%%
## `printf` ## `printf`
The syntax for the format placeholder is `%[flags][width][.precision][length]specifier`. The syntax for the format placeholder is `%[flags][width][.precision][length]specifier`.

View File

@ -8,21 +8,521 @@ tags:
## Overview ## Overview
TODO A type is said to be **derived** if they are defined relative to other types.
## Pointers
Pointers have the same size as the machine's word size since it should be able to refer to any virtual address.
%%ANKI %%ANKI
Basic Basic
*Why* does a pointer's size match the machine's word size? What is a derived type?
Back: Because it should be able to refer to any virtual address. Back: A type defined relative to other types.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1707493017246--> <!--ID: 1727957575885-->
END%% END%%
## Structures ## Aggregate Data Types
The **aggregate data types** are so called because they combine multiple instances of one or several other data types.
%%ANKI
Basic
What are the two aggregate data types?
Back: Arrays and structures.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575896-->
END%%
%%ANKI
Basic
Why are the aggregate data types named the way they are?
Back: They combine multiple instances of one or several other data types.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575904-->
END%%
### Arrays
An array is a contiguous sequence of objects. An array is either a **fixed-length array** (FLA) or a **variable-length array** (VLA).
%%ANKI
Cloze
{Arrays} combine items that all have the same {base type}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575931-->
END%%
%%ANKI
Basic
What is the base type of the following array?
```c
double a[4];
```
Back: `double`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575934-->
END%%
%%ANKI
Basic
What is the base type of the following array?
```c
double a[4][4];
```
Back: `double[4]`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575942-->
END%%
%%ANKI
Basic
How are parentheses introduced to the following declaration without affecting meaning?
```c
double a[4][4];
```
Back:
```c
double (a[4])[4];
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575950-->
END%%
%%ANKI
Basic
Consider the following. How many objects make up `a[0]`?
```c
double a[M][N];
```
Back: `N`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575955-->
END%%
%%ANKI
Basic
Consider the following. How many objects make up `a[M - 1]`?
```c
double a[M][N];
```
Back: `N`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575960-->
END%%
%%ANKI
Basic
Consider the following. How many objects make up `a[N - 1]`?
```c
double a[M][N];
```
Back: Indeterminate. This may not be a valid array access.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575965-->
END%%
%%ANKI
Basic
Consider the following where `N < M`. How many objects make up `a[N - 1]`?
```c
double a[M][N];
```
Back: `N`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575971-->
END%%
%%ANKI
Basic
Consider the following where `M < N`. How many objects make up `a[N - 1]`?
```c
double a[M][N];
```
Back: N/A. Invalid array access.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575977-->
END%%
%%ANKI
Cloze
Array `a[M][N]` is a sequence of {1:`M`} objects each containing {1:`N`} objects.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575984-->
END%%
%%ANKI
Basic
Arrays fall under what two categories?
Back: Fixed-length and variable-length.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575990-->
END%%
%%ANKI
Basic
Where *must* a VLA be declared?
Back: Within a function.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575996-->
END%%
%%ANKI
Basic
What two ways can the length of an FLA be specified?
Back: By an ICE or an initializer.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576002-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
double a[4];
```
Back: FLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576008-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
double a[];
```
Back: N/A. This is invalid syntax.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576013-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
double a[] = { 0 };
```
Back: FLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576019-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
int n = 2;
double a[n];
```
Back: VLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576025-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
#define n 2
double a[n];
```
Back: FLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576030-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
enum { n = 2 };
double a[n];
```
Back: FLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576036-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
int n = 2;
double a[n] = {0};
```
Back: N/A. This is an invalid assignment.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576041-->
END%%
%%ANKI
Basic
For the following to be an FLA, what must `N` be?
```c
double a[N];
```
Back: An ICE.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576047-->
END%%
%%ANKI
Basic
Replace `EXPR` in the following with an expression to compute the length of `A`.
```c
int A[N];
size_t len = EXPR;
```
Back: `(sizeof A) / (sizeof A[0])`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576053-->
END%%
%%ANKI
Basic
What two syntactic forms does the `sizeof` operator come in?
Back: With and without parentheses.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576058-->
END%%
%%ANKI
Basic
When can the `sizeof` operator elide parentheses?
Back: When operating on an object.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576068-->
END%%
%%ANKI
Basic
When does the `sizeof` operator *require* parentheses?
Back: When operating on a type.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576074-->
END%%
%%ANKI
Basic
Apply the possible syntactic forms of the `sizeof` operator to object `a`.
Back:
```c
sizeof a
sizeof(a)
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576079-->
END%%
%%ANKI
Basic
Apply the possible syntactic forms of the `sizeof` operator to type `int`.
Back:
```c
sizeof(int)
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576083-->
END%%
%%ANKI
Basic
Suppose I pass the following array to a function. Which dimension is lost?
```c
double a[M][N][P];
```
Back: `M`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147560-->
END%%
%%ANKI
Basic
Suppose I pass the following array to a function. What does the parameter look like?
```c
double a[M][N][P];
```
Back:
```c
double a[][N][P];
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147578-->
END%%
%%ANKI
Basic
Why shouldn't you use the `sizeof` operator on array parameters to functions?
Back: The innermost dimension of an array parameter to a function is lost.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147581-->
END%%
%%ANKI
Basic
How is the following array parameter rewritten using pointer syntax?
```c
void foo(int a[const]) {}
```
Back:
```c
void foo(int *const a) {}
```
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: 1728244147585-->
END%%
%%ANKI
Basic
How is the following array parameter rewritten using pointer syntax?
```c
void foo(const int a[]) {}
```
Back:
```c
void foo(const int *a) {}
```
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: 1728244147614-->
END%%
%%ANKI
Basic
How is the following pointer parameter rewritten using array syntax?
```c
void foo(int *restrict a) {}
```
Back:
```c
void foo(int a[restrict]) {}
```
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: 1728244147617-->
END%%
%%ANKI
Basic
How is the following pointer parameter rewritten using array syntax?
```c
void foo(volatile int *a) {}
```
Back:
```c
void foo(volatile int a[]) {}
```
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: 1728244147620-->
END%%
%%ANKI
Basic
What does the `3` keyword guarantee to the compiler?
```c
void bar(int a[3]);
```
Back: N/A. It is ignored.
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: 1728244147623-->
END%%
%%ANKI
Basic
*Why* might you see e.g. `3` like in the following prototype?
```c
void bar(int a[3]);
```
Back: It serves as documentation.
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: 1728244147625-->
END%%
%%ANKI
Basic
In the following, what does the `static` keyword guarantee to the compiler?
```c
void bar(int a[static 3]);
```
Back: The minimum number of elements for the compiler to assume `a` contains.
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: 1728244147628-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[3]);
int main() {
int a[] = { 1, 2 };
foo(a);
}
```
Back: N/A. It doesn't.
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: 1728244147652-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[static 3]);
int main() {
int a[] = { 1, 2 };
foo(a);
}
```
Back: Because the argument to `foo` does not have at least `3` elements.
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: 1728244147655-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[static 3]);
int main() {
int a[] = { 1, 2, 3, 4 };
foo(a);
}
```
Back: N/A. It doesn't.
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: 1728244147658-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[3]);
int main() {
foo(0);
}
```
Back: N/A. It doesn't.
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: 1728244147661-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[static 1]);
int main() {
foo(0);
}
```
Back: Because `static` indicates a valid pointer must be passed to `foo`.
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: 1728244147664-->
END%%
### Structures
A `struct` is a grouping of data together. It has the following general form: A `struct` is a grouping of data together. It has the following general form:
@ -34,6 +534,13 @@ struct optional_tag {
} optional_var1 ... optional_varM; } optional_var1 ... optional_varM;
``` ```
%%ANKI
Cloze
{Structures} combine items that may have different {base types}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576087-->
END%%
%%ANKI %%ANKI
Basic Basic
What is the underlined portion of the following declaration called? What is the underlined portion of the following declaration called?
@ -112,8 +619,21 @@ Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Progra
<!--ID: 1722786892131--> <!--ID: 1722786892131-->
END%% END%%
## Pointers
Pointers have the same size as the machine's word size since it should be able to refer to any virtual address.
%%ANKI
Basic
*Why* does a pointer's size match the machine's word size?
Back: Because it should be able to refer to any virtual address.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1707493017246-->
END%%
## Bibliography ## Bibliography
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. * Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
* “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).
* 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.

View File

@ -461,7 +461,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What is the minimum width of an `unsigned long long`? What is the minimum width of an `unsigned long long`?
Back: $64$ Back: $64$ bits.
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: 1727613641635--> <!--ID: 1727613641635-->
END%% END%%

View File

@ -98,14 +98,6 @@ Reference: Donald Ervin Knuth, _Art of Computer Programming, 3: Sorting and Sear
<!--ID: 1723211542028--> <!--ID: 1723211542028-->
END%% END%%
%%ANKI
Basic
What is the minimum number of keys a non-root node in a B-tree can have?
Back: N/A. It depends on the tree's order.
Reference: Donald Ervin Knuth, _Art of Computer Programming, 3: Sorting and Searching_, 2. ed., 34. (Reading, Mass: Addison-Wesley, 1995).
<!--ID: 1723211542035-->
END%%
%%ANKI %%ANKI
Basic Basic
What is the minimum number of keys a non-root node in a B-tree of order $m$ can have? What is the minimum number of keys a non-root node in a B-tree of order $m$ can have?

View File

@ -1168,7 +1168,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
Suppose $x \neq y$. *Why* isn't the following a tautology? $$\large{E_{e_1, e_2, e_3, e_4}^{x[1], x[2], y, x[3]}} = E_{(x; \,[1]{:}e_1; \,[2]{:}e_2), e_3, e_4}^{x, y, x[3]}$$ Suppose $x \neq y$. *Why* isn't the following a tautology? $$\large{E_{e_1, e_2, e_3, e_4}^{x[1], x[2], y, x[3]}} = E_{(x; \,[1]{:}e_1; \,[2]{:}e_2), e_3, e_4}^{x, y, x[3]}$$
Back: Because not every $x$ was made adjacent before grouping. Back: N/A. It is.
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981. Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
<!--ID: 1721495879859--> <!--ID: 1721495879859-->
END%% END%%

View File

@ -21,7 +21,7 @@ END%%
%%ANKI %%ANKI
Cloze Cloze
Proof systems are {syntactic}, not {semantic}. Proof systems are {syntactic} not {semantic}.
Reference: “Formal System,” in _Wikipedia_, May 10, 2024, [https://en.wikipedia.org/w/index.php?title=Formal_system](https://en.wikipedia.org/w/index.php?title=Formal_system&oldid=1223254138). Reference: “Formal System,” in _Wikipedia_, May 10, 2024, [https://en.wikipedia.org/w/index.php?title=Formal_system](https://en.wikipedia.org/w/index.php?title=Formal_system&oldid=1223254138).
<!--ID: 1721561534211--> <!--ID: 1721561534211-->
END%% END%%

View File

@ -36,7 +36,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
How does Knuth define a *dynamic* set? How does Cormen et al. define a *dynamic* set?
Back: As a set that can change over time. Back: As a set that can change over time.
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).
Tags: adt::dynamic_set Tags: adt::dynamic_set
@ -45,7 +45,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
How does Knuth distinguish mathematical sets from dynamic sets? How does Cormen et al. distinguish mathematical sets from dynamic sets?
Back: The former is assumed to be unchanging. Back: The former is assumed to be unchanging.
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).
Tags: adt::dynamic_set Tags: adt::dynamic_set
@ -54,7 +54,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
How does Knuth define a dictionary? How does Cormen et al. define a dictionary?
Back: As a dynamic set that allows insertions, deletions, and membership tests. Back: As a dynamic set that allows insertions, deletions, and membership tests.
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).
Tags: adt::dynamic_set Tags: adt::dynamic_set

View File

@ -469,11 +469,19 @@ END%%
%%ANKI %%ANKI
Basic Basic
What condition of Peano system $\langle N, S, e \rangle$ generalizes the induction principle of $\omega$? What condition of Peano system $\langle N, S, e \rangle$ generalizes the induction principle of $\omega$?
Back: Any set $A \subseteq N$ containing $e$ and closed under $S$ coincides with $N$. Back: The Peano induction postulate.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1726364667661--> <!--ID: 1726364667661-->
END%% END%%
%%ANKI
Basic
Given Peano system $\langle N, S, e \rangle$, what does the Peano induction postulate state?
Back: Any set $A \subseteq N$ containing $e$ and closed under $S$ coincides with $N$.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1727895401785-->
END%%
%%ANKI %%ANKI
Basic Basic
What name is given to the condition of Peano systems involving closures? What name is given to the condition of Peano systems involving closures?
@ -852,7 +860,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
The recursion theorem assumes existence of what Peano system? The recursion theorem on $\omega$ assumes existence of what Peano system?
Back: $\langle \omega, \sigma, 0 \rangle$ where $\sigma$ is the successor operation restricted to the natural numbers. Back: $\langle \omega, \sigma, 0 \rangle$ where $\sigma$ is the successor operation restricted to the natural numbers.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1727629020357--> <!--ID: 1727629020357-->
@ -965,7 +973,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
In Enderton's recursion theorem proof, function $h \colon \omega \rightarrow A$ is defined as the union of what? In Enderton's recursion theorem proof, function $h \colon \omega \rightarrow A$ is defined as the union of what?
Back: All "acceptable" functions. Back: The set of "acceptable" functions.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1727627702457--> <!--ID: 1727627702457-->
END%% END%%
@ -1004,7 +1012,7 @@ END%%
\ \
%%ANKI %%ANKI
Basic Basic
In Enderton's recursion theorem proof, what term refers to the "approximating" functions? In Enderton's recursion theorem proof, what term is used to refer to the "approximating" functions?
Back: They are called "acceptable". Back: They are called "acceptable".
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1727627702465--> <!--ID: 1727627702465-->
@ -1019,7 +1027,7 @@ END%%
%%ANKI %%ANKI
Cloze Cloze
In Enderton's recursion theorem proof, desired $h \colon \omega \rightarrow A$ is {a function} because {$\{ n \in \omega \mid \text{ at most one } y \text{ such that } \langle n, y \rangle \in h \}$} is {an inductive set}. In Enderton's recursion theorem proof, desired $h \colon \omega \rightarrow A$ is {a function} because {$\{ n \in \omega \mid \text{at most one } y \text{ such that } \langle n, y \rangle \in h \}$} is {an inductive set}.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1727627702468--> <!--ID: 1727627702468-->
END%% END%%
@ -1049,7 +1057,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
*Why* is there no function $h \colon \mathbb{N} \rightarrow \mathbb{N}$ such that for all $n \in \mathbb{N}$$, $$\begin{align*} h(0) & = 0 \\ h(n + 1) & = h(n) + 1 \end{align*}$$ *Why* is there no function $h \colon \mathbb{N} \rightarrow \mathbb{N}$ such that for all $n \in \mathbb{N}$, $$\begin{align*} h(0) & = 0 \\ h(n + 1) & = h(n) + 1 \end{align*}$$
Back: N/A. The resursive theorem of $\omega$ states such an $h$ exists. Back: N/A. The resursive theorem of $\omega$ states such an $h$ exists.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1727629020375--> <!--ID: 1727629020375-->

View File

@ -603,11 +603,19 @@ END%%
%%ANKI %%ANKI
Basic Basic
Is $\{A\}$ a partition of set $A$? Is $\{A\}$ a partition of set $A$?
Back: Yes. Back: Not necessarily.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977). Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1721098094091--> <!--ID: 1721098094091-->
END%% END%%
%%ANKI
Basic
When is $\{A\}$ a partition of set $A$?
Back: When $A \neq \varnothing$.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1727951100840-->
END%%
%%ANKI %%ANKI
Basic Basic
Let $A = \{1, 2, 3, 4\}$. Why isn't $\{\{1, 2\}, \{2, 3, 4\}\}$ a partition of $A$? Let $A = \{1, 2, 3, 4\}$. Why isn't $\{\{1, 2\}, \{2, 3, 4\}\}$ a partition of $A$?

View File

@ -87,7 +87,7 @@ Assume `%rbx` holds $p$ and `%rdx` holds $q$. What is the value of `%rax` in the
```asm ```asm
leaq (%rdx, %rbx),%rax leaq (%rdx, %rbx),%rax
``` ```
Back: $q + q$ Back: $q + p$
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: 1715781031935--> <!--ID: 1715781031935-->
END%% END%%

View File

@ -929,6 +929,68 @@ Tags: c17
<!--ID: 1727632288468--> <!--ID: 1727632288468-->
END%% END%%
%%ANKI
Basic
What efficient data structure do `switch` statements compile down into?
Back: Jump tables.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1727908553985-->
END%%
%%ANKI
Basic
What two conditions must be satisfied before a `switch` statement employs a jump table?
Back: A sufficient number of `case` statements that span a small range of values.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1727908554004-->
END%%
%%ANKI
Basic
*Why* might a `switch` statements be faster than an equivalent `if`/`else` chain?
Back: A `switch` statement can compile down into a jump table.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1727908554023-->
END%%
%%ANKI
Basic
What is a jump table?
Back: An array of (code) memory locations to potentially jump to.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1727908554057-->
END%%
%%ANKI
Basic
Suppose a `switch` compiles into a jump table. What *is* a missing case?
Back: An offset in the jump table corresponding to an unspecified `case` statement.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1727908554070-->
END%%
%%ANKI
Basic
Suppose a `switch` compiles into a jump table. How are missing cases handled?
Back: By using the label (memory location) for the default case.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1727908554114-->
END%%
%%ANKI
Basic
Suppose a `switch` compiles into a jump table. How are duplicate cases handled?
Back: By using the same label (memory location) for all duplicate cases.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1727908554128-->
END%%
### CMOV ### CMOV
Like [[access#MOV|MOV]] instructions, but with the data transfer only happening if the move condition is satisfied. Like [[access#MOV|MOV]] instructions, but with the data transfer only happening if the move condition is satisfied.