Basic ADTs.
parent
a9d0925080
commit
5f8017ba3d
|
@ -119,7 +119,11 @@
|
|||
"max-heap-array.png",
|
||||
"max-heapify-1.png",
|
||||
"max-heapify-2.png",
|
||||
"heapsort.gif"
|
||||
"heapsort.gif",
|
||||
"array-1d-row-major.png",
|
||||
"array-1d-col-major.png",
|
||||
"array-multi-row-major.png",
|
||||
"array-multi-col-major.png"
|
||||
],
|
||||
"File Hashes": {
|
||||
"algorithms/index.md": "3ac071354e55242919cc574eb43de6f8",
|
||||
|
@ -150,7 +154,7 @@
|
|||
"posix/regexp.md": "cb53e537fc10ce83307f35497d48179f",
|
||||
"journal/2024-02-04.md": "e2b5678fc53d7284b71ed6820c02b954",
|
||||
"gawk/regexp.md": "d9229f1eabe1b99e965eecaa03bee86c",
|
||||
"_templates/daily.md": "5863e4524f8d012e153918d238c611a4",
|
||||
"_templates/daily.md": "bfcd221502a23a285af100317b6ef127",
|
||||
"_journal/2024-02-05.md": "f8505abd415c50fd97c81fd6153a6d4f",
|
||||
"_journal/2024-02-06.md": "1ea415f3c3f5be17f796b9a0d4df565f",
|
||||
"_journal/2024-02-04.md": "f77a3c5f3ce7969120f226738836dc92",
|
||||
|
@ -220,7 +224,7 @@
|
|||
"_journal/2024-02-19.md": "30d16c5373deb9cb128d2e7934ae256a",
|
||||
"_journal/2024-02/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629",
|
||||
"combinatorics/permutations.md": "1b994b48798699655ee64df29c640251",
|
||||
"combinatorics/combinations.md": "1109af89c5f3343ef978e4385c4b3819",
|
||||
"combinatorics/combinations.md": "ce13308125a137c1fb1ed3918dbe5ccc",
|
||||
"_journal/2024-02-20.md": "b85ba0eeeb16e30a602ccefabcc9763e",
|
||||
"_journal/2024-02/2024-02-19.md": "df1a9ab7ab89244021b3003c84640c78",
|
||||
"combinatorics/inclusion-exclusion.md": "c27b49ee03cc5ee854d0e8bd12a1d505",
|
||||
|
@ -268,7 +272,7 @@
|
|||
"_journal/2024-03-05.md": "e9a911c19bb4c0ff451db793248cb4bb",
|
||||
"_journal/2024-03/2024-03-04.md": "4948d90a08af2cff58c629c9a2e11ee4",
|
||||
"algebra/sequences/geometric.md": "57544cab59f0b8c28d4a11f0273a3119",
|
||||
"algebra/sequences/arithmetic.md": "861b6368487463a4fd6a608147df2f4f",
|
||||
"algebra/sequences/arithmetic.md": "63cb1bd3a0d01942f4f7a4212c742cfd",
|
||||
"_journal/2024-03-06.md": "ac7a3d764934f49b2be7aa76e402d853",
|
||||
"_journal/2024-03/2024-03-05.md": "94b28d0b9bc62cc0bd99d315fb7c6d30",
|
||||
"_journal/2024-03-07.md": "7bf68d6d81e89aa00f5ddd7510b69e3e",
|
||||
|
@ -299,7 +303,7 @@
|
|||
"_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f",
|
||||
"_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b",
|
||||
"set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53",
|
||||
"set/index.md": "b82a215fbee3c576186fc1af93c82fcb",
|
||||
"set/index.md": "f2e907b2643cd4e5023169dcd96ca828",
|
||||
"set/graphs.md": "242195a7af5dc5dfefdc07ccba8b0fa4",
|
||||
"_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb",
|
||||
"_journal/2024-03/2024-03-18.md": "63c3c843fc6cfc2cd289ac8b7b108391",
|
||||
|
@ -318,7 +322,7 @@
|
|||
"_journal/2024-03-22.md": "8da8cda07d3de74f7130981a05dce254",
|
||||
"_journal/2024-03/2024-03-21.md": "cd465f71800b080afa5c6bdc75bf9cd3",
|
||||
"x86-64/declarations.md": "75bc7857cf2207a40cd7f0ee056af2f2",
|
||||
"x86-64/instructions.md": "b34217258f8dd5a738fb3296d0ac744c",
|
||||
"x86-64/instructions.md": "eef92b487920c7a15f38955c97a48a2d",
|
||||
"git/refs.md": "954fc69004aa65b358ec5ce07c1435ce",
|
||||
"set/trees.md": "0d21b947917498f107da140cc9fb93a7",
|
||||
"_journal/2024-03-24.md": "1974cdb9fc42c3a8bebb8ac76d4b1fd6",
|
||||
|
@ -399,14 +403,25 @@
|
|||
"data-structures/heaps.md": "0cba4acb7667dcab80fa4e7778e86cc8",
|
||||
"data-structures/index.md": "2605977fad54956b5dc2d8dda9be2b10",
|
||||
"abstract-data-types/priority-queues.md": "d3dad736cb05c47bdc93c52a3a4af083",
|
||||
"abstract-data-types/index.md": "2c287ebe88f9cce0ea9fba1311b6a3a6",
|
||||
"abstract-data-types/index.md": "6b110b20393c561497629ca4c3e09472",
|
||||
"_journal/2024-05-04.md": "679934dc63ded49503d573b8d2046e5d",
|
||||
"_journal/2024-05/2024-05-03.md": "be21fe4d9c1c24f74a74d06d07f8e90b",
|
||||
"_journal/2024-05/2024-05-02.md": "d7d6ba7e065d807986f0bd77281c0bb1",
|
||||
"_journal/2024-05/2024-05-01.md": "959ff67fe3db585ba6a7b121d853bbac",
|
||||
"_journal/2024-04/2024-04-30.md": "369f98b9d91de89cc1f4f581bc530c0d",
|
||||
"_journal/2024-05-06.md": "bc9306348b7063b87741768391d9d8a7",
|
||||
"_journal/2024-05/2024-05-04.md": "866af1876896a343e7a7d9d09d0c24bb"
|
||||
"_journal/2024-05/2024-05-04.md": "866af1876896a343e7a7d9d09d0c24bb",
|
||||
"_journal/2024-05-09.md": "c2c84166b15df42c8243fc1be0550aac",
|
||||
"_journal/2024-05/2024-05-08.md": "0f1b1b9e2abcf3203b511b9e034e86f4",
|
||||
"_journal/2024-05/2024-05-07.md": "4b1dde039a251f9a6dc7e606de98616d",
|
||||
"_journal/2024-05/2024-05-06.md": "bc9306348b7063b87741768391d9d8a7",
|
||||
"_journal/2024-05-10.md": "b594772387b409cd38245d8b319260ae",
|
||||
"data-structures/arrays.md": "1c648464841ee2cc86382ca176890950",
|
||||
"_journal/2024-05-11.md": "3448f51b254fecca15b310d03881d734",
|
||||
"_journal/2024-05/2024-05-10.md": "036bda39b619b2719dc763516d8de096",
|
||||
"_journal/2024-05/2024-05-09.md": "c2c84166b15df42c8243fc1be0550aac",
|
||||
"abstract-data-types/queues.md": "db668234b6c6051635321730b7176dcb",
|
||||
"abstract-data-types/stacks.md": "d4324db19a88211dc6bf4f0e56c74cec"
|
||||
},
|
||||
"fields_dict": {
|
||||
"Basic": [
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
title: "2024-05-12"
|
||||
---
|
||||
|
||||
- [x] Anki Flashcards
|
||||
- [x] KoL
|
||||
- [ ] Sheet Music (10 min.)
|
||||
- [ ] Go (1 Life & Death Problem)
|
||||
- [ ] Korean (Read 1 Story)
|
|
@ -12,4 +12,5 @@ title: "2024-05-09"
|
|||
* Accepted job with Pranav so can drop the work and interview prep TODOs.
|
||||
* Databases
|
||||
* Watched [Lecture #08](https://www.youtube.com/watch?v=9QPr8Ufzt5M8&list=PLSE8ODhjZXjaKScG3l0nuOiDTTqpfnWFf&index=8) on tree indices.
|
||||
* Read chapter 14.1-14.4 of "Database Concepts".
|
||||
* Read chapter 14.1-14.4 of "Database Concepts".
|
||||
* Finished a number of issues opened by Gus and Addie for Hide and Seek.
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: "2024-05-10"
|
||||
---
|
||||
|
||||
- [x] Anki Flashcards
|
||||
- [x] KoL
|
||||
- [ ] Sheet Music (10 min.)
|
||||
- [ ] Go (1 Life & Death Problem)
|
||||
- [ ] Korean (Read 1 Story)
|
||||
|
||||
* Made half-baked answers to [Homework #2](https://15445.courses.cs.cmu.edu/fall2022/files/hw2-clean.pdf) for the CMU DB course.
|
||||
* Added `pushq` and `popq` flashcards.
|
||||
* Progressed on an issue opened by Gus and Addie for Hide and Seek.
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
title: "2024-05-11"
|
||||
---
|
||||
|
||||
- [x] Anki Flashcards
|
||||
- [x] KoL
|
||||
- [ ] Sheet Music (10 min.)
|
||||
- [ ] Go (1 Life & Death Problem)
|
||||
- [ ] Korean (Read 1 Story)
|
||||
|
||||
* Basic notes on stacks/queues/arrays.
|
||||
* Continuing fixing up open issues for Hide and Seek in anticipation of next playthrough.
|
|
@ -41,6 +41,27 @@ Reference: “Abstract Data Type.” In _Wikipedia_, March 18, 2024. [https://en
|
|||
<!--ID: 1714677608770-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{1:FIFO} is to {2:queues} as {2:LIFO} is to {1:stacks}.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853935-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{`PUSH`} is to stacks as {`ENQUEUE`} is to queues.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853939-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{`POP`} is to stacks as {`DEQUEUE`} is to queues.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853943-->
|
||||
END%%
|
||||
|
||||
## Bibliography
|
||||
|
||||
* “Abstract Data Type.” In _Wikipedia_, March 18, 2024. [https://en.wikipedia.org/w/index.php?title=Abstract_data_type&oldid=1214359576](https://en.wikipedia.org/w/index.php?title=Abstract_data_type&oldid=1214359576).
|
|
@ -0,0 +1,85 @@
|
|||
---
|
||||
title: Queues
|
||||
TARGET DECK: Obsidian::STEM
|
||||
FILE TAGS: adt::queue
|
||||
tags:
|
||||
- adt
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which abstract data type is most strongly associated with FIFO?
|
||||
Back: The queue.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853851-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does FIFO stand for?
|
||||
Back: **F**irst **i**n, **f**irst **o**ut.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853856-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is a queue's insertion method typically called?
|
||||
Back: `ENQUEUE`
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853859-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is a queue's deletion method typically called?
|
||||
Back: `DEQUEUE`
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853863-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which element of a queue is deleted on `DEQUEUE`?
|
||||
Back: The firstmost element.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853866-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean for a queue to overflow?
|
||||
Back: An `ENQUEUE` was requested but the underlying data structure is full.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853870-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What queue method can invoke an overflow?
|
||||
Back: `ENQUEUE`
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853873-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean for a queue to underflow?
|
||||
Back: A `DEQUEUE` was requested but no elements exist in the queue.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853877-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What queue method can invoke an underflow?
|
||||
Back: `DEQUEUE`
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853881-->
|
||||
END%%
|
||||
|
||||
## Bibliography
|
||||
|
||||
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
|
@ -0,0 +1,85 @@
|
|||
---
|
||||
title: Stacks
|
||||
TARGET DECK: Obsidian::STEM
|
||||
FILE TAGS: adt::stack
|
||||
tags:
|
||||
- adt
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which abstract data type is most strongly associated with LIFO?
|
||||
Back: The stack.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853887-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does LIFO stand for?
|
||||
Back: **L**ast **i**n, **f**irst **o**ut.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853892-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is a stack's insertion method typically called?
|
||||
Back: `PUSH`
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853897-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is a stack's deletion method typically called?
|
||||
Back: `POP`
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853903-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which element of a stack is deleted on `POP`?
|
||||
Back: The top element.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853908-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean for a stack to overflow?
|
||||
Back: A `PUSH` was requested but the underlying data structure is full.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853914-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What stack method can invoke an overflow?
|
||||
Back: `PUSH`
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853919-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean for a stack to underflow?
|
||||
Back: A `POP` was requested but no elements exist in the stack.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853925-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What stack method can invoke an underflow?
|
||||
Back: `POP`
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715461853930-->
|
||||
END%%
|
||||
|
||||
## Bibliography
|
||||
|
||||
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
|
@ -115,7 +115,7 @@ END%%
|
|||
|
||||
%%ANKI
|
||||
Basic
|
||||
Interpreted as an arithmetic sequence, what is the common ratio of the triangular numbers?
|
||||
Interpreted as an arithmetic sequence, what is the common difference of the triangular numbers?
|
||||
Back: $1$
|
||||
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: 1709664600178-->
|
||||
|
|
|
@ -72,7 +72,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
How is $\binom{n}{k}$ combinations of $n$ objects derived?
|
||||
Back: As $(n)_k$ $k$-permutations of $n$ divided by $k!$, the numer of possible $k$-orderings.
|
||||
Back: As $(n)_k$ $k$-permutations of $n$ divided by $k!$, the number of possible $k$-orderings.
|
||||
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: 1708368078695-->
|
||||
END%%
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
---
|
||||
title: Arrays
|
||||
TARGET DECK: Obsidian::STEM
|
||||
FILE TAGS: data_structure::array
|
||||
tags:
|
||||
- array
|
||||
- data_structure
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean to store a matrix in row-major order?
|
||||
Back: Entries in the same matrix rows are adjacent to each other in memory.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715460959164-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What does it mean to store a matrix in column-major order?
|
||||
Back: Entries in the same matrix columns are adjacent to each other in memory.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715460973182-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is the following matrix stored as a one-dimensional array in row-major order?
|
||||
$$M = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}$$
|
||||
Back:
|
||||
![[array-1d-row-major.png]]
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715460959175-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is the following matrix stored as a one-dimensional array in column-major order?
|
||||
$$M = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}$$
|
||||
Back:
|
||||
![[array-1d-col-major.png]]
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715460959179-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is the following matrix stored as an array of arrays in row-major order?
|
||||
$$M = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}$$
|
||||
Back:
|
||||
![[array-multi-row-major.png]]
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715460959183-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is the following matrix stored as an array of arrays in column-major order?
|
||||
$$M = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}$$
|
||||
Back:
|
||||
![[array-multi-col-major.png]]
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1715460959188-->
|
||||
END%%
|
||||
|
||||
## Bibliography
|
||||
|
||||
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
|
@ -91,7 +91,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
What two sizes are associated with binary heaps?
|
||||
Back: The number of valid elements and the size of the underlying array.
|
||||
Back: The size of the heap and the capacity of the underlying array.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
<!--ID: 1714356379038-->
|
||||
END%%
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
|
@ -5,3 +5,71 @@ FILE TAGS: set
|
|||
tags:
|
||||
- set
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How does Knuth define a *dynamic* set?
|
||||
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).
|
||||
Tags: adt::dynamic_set
|
||||
<!--ID: 1715432070055-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How does Knuth distinguish mathematical sets from dynamic sets?
|
||||
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).
|
||||
Tags: adt::dynamic_set
|
||||
<!--ID: 1715432070059-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How does Knuth define a dictionary?
|
||||
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).
|
||||
Tags: adt::dynamic_set
|
||||
<!--ID: 1715432070063-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which of dynamic sets and dictionaries are more general?
|
||||
Back: The dynamic set.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
Tags: adt::dynamic_set
|
||||
<!--ID: 1715432070067-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is a dynamic set a dictionary?
|
||||
Back: Not necessarily.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
Tags: adt::dynamic_set
|
||||
<!--ID: 1715432070071-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Is a dictionary a dynamic set?
|
||||
Back: Yes.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
Tags: adt::dynamic_set
|
||||
<!--ID: 1715432070077-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
A dictionary supports {insertions}, {deletions}, and {membership testing}.
|
||||
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||
Tags: adt::dynamic_set
|
||||
<!--ID: 1715432070083-->
|
||||
END%%
|
||||
|
||||
## Bibliography
|
||||
|
||||
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
|
@ -367,6 +367,30 @@ END%%
|
|||
|
||||
### `MOV`
|
||||
|
||||
The MOV instruction class has four primary variants: `movb`, `movw`, `movl`, and `movq`. There also exist zero extension and sign extension variations in the forms of MOVS and MOVZ.
|
||||
|
||||
| Instruction | Operands | Effect | Description |
|
||||
| ----------- | -------- | ---------------- | ------------------------------------------- |
|
||||
| `movb` | S, D | D <- S | Move byte |
|
||||
| `movw` | S, D | D <- S | Move word |
|
||||
| `movl` | S, D | D <- S | Move double word |
|
||||
| `movq` | S, D | D <- S | Move quad word |
|
||||
| `movabsq` | I, R | R <- I | Move quad word |
|
||||
| `movzbw` | S, R | R <- ZE(S) | Move zero-extended byte to word |
|
||||
| `movzbl` | S, R | R <- ZE(S) | Move zero-extended byte to double word |
|
||||
| `movzwl` | S, R | R <- ZE(S) | Move zero-extended word to double word |
|
||||
| `movzbq` | S, R | R <- ZE(S) | Move zero-extended byte to quad word |
|
||||
| `movzwq` | S, R | R <- ZE(S) | Move zero-extended word to quad word |
|
||||
| `movsbw` | S, R | R <- SE(S) | Move sign-extended byte to word |
|
||||
| `movsbl` | S, R | R <- SE(S) | Move sign-extended byte to double word |
|
||||
| `movswl` | S, R | R <- SE(S) | Move sign-extended word to double word |
|
||||
| `movsbq` | S, R | R <- SE(S) | Move sign-extended byte to quad word |
|
||||
| `movswq` | S, R | R <- SE(S) | Move sign-extended word to quad word |
|
||||
| `movslq` | S, R | R <- SE(S) | Move sign-extended double word to quad word |
|
||||
| `cltq` | | %rax <- SE(%eax) | Sign-extend `%eax` to `%rax` |
|
||||
|
||||
Notice there is no `movzlq` instruction. `movl` covers this functionality since, by convention, instructions moving double words into a 64-bit register automatically zeroes out the upper 32 bits.
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What four variants does `MOV` instructions take on in x86-64?
|
||||
|
@ -586,7 +610,7 @@ END%%
|
|||
%%ANKI
|
||||
Basic
|
||||
Why does there not exist a `movzlq` instruction?
|
||||
Back: Because `movl` already zeros out the upper bits of a destination register.
|
||||
Back: Because `movl` already zeroes out the upper bits of a destination register.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1713625933483-->
|
||||
END%%
|
||||
|
@ -647,6 +671,109 @@ Tags: c17
|
|||
<!--ID: 1714677608758-->
|
||||
END%%
|
||||
|
||||
### PUSH and POP
|
||||
|
||||
| Instruction | Operands | Effect | Description |
|
||||
| ----------- | -------- | ------------------------------------------- | -------------- |
|
||||
| `pushq` | S | R[%rsp] <- R[%rsp] - 8<br />M[R[%rsp]] <- S | Push quad word |
|
||||
| `popq` | D | D <- M[R[%rsp]]<br />R[%rsp] <- R[%rsp] + 8 | Pop quad word |
|
||||
|
||||
In x86 processors, the stack grows downward, with the "top" of the stack corresponding to lower addresses.
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
In what direction do x86-64 stacks grow?
|
||||
Back: Downward.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284944-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
The x86-64 stack grows such that the top element has the {lowest} address of all stack elements.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284947-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What instruction is used to push elements onto the stack?
|
||||
Back: `pushq`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284951-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What instruction is used to pop elements off of the stack?
|
||||
Back: `popq`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284955-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is `pushq %rbp` equivalently written using a pair of instructions?
|
||||
Back:
|
||||
```asm
|
||||
subq 8,%rsp
|
||||
movq %rbp,(%rsp)
|
||||
```
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284959-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
How is `popq %rax` equivalently written using a pair of instructions?
|
||||
Back:
|
||||
```asm
|
||||
movq (%rsp),%rax
|
||||
addq 8,%rsp
|
||||
```
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284962-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Cloze
|
||||
{1:`pushq`} is to {2:`subq`} as {2:`popq`} is to {1:`addq`}.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284966-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
If `%rsp` has value `0x108`, what value does it have after a `pushq` instruction?
|
||||
Back: `0x100`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284971-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
If `%rsp` has value `0x108`, what value does it have after a `popq` instruction?
|
||||
Back: `0x110`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284975-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
Which register contains a pointer to the top of the stack?
|
||||
Back: `%rsp`
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284980-->
|
||||
END%%
|
||||
|
||||
%%ANKI
|
||||
Basic
|
||||
What is the `%rsp` register typically used for?
|
||||
Back: The stack pointer.
|
||||
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
<!--ID: 1715377284985-->
|
||||
END%%
|
||||
|
||||
## Bibliography
|
||||
|
||||
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
|
||||
|
|
Loading…
Reference in New Issue