Notes on graphs.

c-declarations
Joshua Potter 2024-03-18 18:28:34 -06:00
parent 809414ede4
commit 33466a2583
17 changed files with 1340 additions and 277 deletions

View File

@ -100,12 +100,14 @@
"normalized-form.png",
"denormalized-form.png",
"infinity.png",
"nan.png"
"nan.png",
"directed-graph-example.png",
"undirected-graph-example.png"
],
"File Hashes": {
"algorithms/index.md": "cd7c7ba91fb2f961c9f2437777e8e2ac",
"algorithms/index.md": "f63290ca8d7aad1840797ec699188e9e",
"algorithms/sorting/index.md": "2d5a18a3079d96fa9e3d4289181a8b6c",
"algorithms/sorting/insertion-sort.md": "10525c1e013a341ef51656bedf41a61b",
"algorithms/sorting/insertion-sort.md": "bdac9a5836611d6136b65367bed521e7",
"bash/index.md": "3e4738d8d3531bb7a5afc53a2d73036c",
"bash/prompts.md": "61cb877e68da040a15b85af76b1f68ba",
"bash/quoting.md": "b1d8869a91001f8b22f0cdc54d806f61",
@ -142,11 +144,11 @@
"logic/equiv-trans.md": "315997b803b0748f5fc76d912ad97cda",
"_journal/2024-02-07.md": "8d81cd56a3b33883a7706d32e77b5889",
"algorithms/loop-invariants.md": "cbefc346842c21a6cce5c5edce451eb2",
"algorithms/loop-invariant.md": "29f9f9090a3109890d333a78acc18b50",
"algorithms/loop-invariant.md": "e39f4aa253f0baf908067bea81f6bced",
"algorithms/running-time.md": "5efc0791097d2c996f931c9046c95f65",
"algorithms/order-growth.md": "0148c1e9f4aa89cc8a7fcf44666805d0",
"algorithms/order-growth.md": "53d41d9abbd1d8118793bad3996d249a",
"_journal/2024-02-08.md": "19092bdfe378f31e2774f20d6afbfbac",
"algorithms/sorting/selection-sort.md": "3e4f059f01210d050ec6e7279e93e43c",
"algorithms/sorting/selection-sort.md": "997feca70660168b3a115df6b5d5672e",
"algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97",
"binary/hexadecimal.md": "c3d485f1fd869fe600334ecbef7d5d70",
"binary/index.md": "9089c6f0e86a0727cd03984f51350de0",
@ -154,7 +156,7 @@
"c/types.md": "cf3e66e5aee58a94db3fdf0783908555",
"logic/quantification.md": "346ebe70e1fad9d95d81056ec9029793",
"c/declarations.md": "2de27f565d1020819008ae80593af435",
"algorithms/sorting/bubble-sort.md": "96c4b9426bcb4284de60b9144ba09b9e",
"algorithms/sorting/bubble-sort.md": "a350fb36d1e677659142bf38f7abc89b",
"_journal/2024-02-10.md": "562b01f60ea36a3c78181e39b1c02b9f",
"_journal/2024-01/2024-01-31.md": "7c7fbfccabc316f9e676826bf8dfe970",
"_journal/2024-02/2024-02-09.md": "a798d35f0b2bd1da130f7ac766166109",
@ -189,7 +191,7 @@
"_journal/2024-02/2024-02-15.md": "16cb7563d404cb543719b7bb5037aeed",
"algebra/floor-ceiling.md": "556406772daaa415d546b1a8bf41b5dd",
"algebra/index.md": "90b842eb694938d87c7c68779a5cacd1",
"algorithms/binary-search.md": "27189885f0bc1e8b8b9049da3ed92f98",
"algorithms/binary-search.md": "f88a5b9f38f1856f2bd4f578d6079548",
"_journal/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048",
"_journal/2024-02/2024-02-16.md": "e701902e369ec53098fc2deed4ec14fd",
"binary/integer-encoding.md": "7ace6ab6c5a4191ae0abdfe7e5abb6a2",
@ -214,9 +216,9 @@
"_journal/2024-02/2024-02-22.md": "312e55d57868026f6e80f7989a889c2b",
"c17/strings.md": "3335356dee2b0e28a356adc851ee1375",
"c17/index.md": "78576ee41d0185df82c59999142f4edb",
"c17/escape-sequences.md": "ebc63c6cdfbe60bbc2708c1b0c8da8bb",
"c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500",
"c17/declarations.md": "cec6866dff8ad160467df62cfceb6872",
"algorithms/sorting/merge-sort.md": "fdc6311b0f9e7d85899fc77a95872a2f",
"algorithms/sorting/merge-sort.md": "e0e9108566d2de0ff9fd211a573fca8d",
"_journal/2024-02-24.md": "9bb319d5014caf962a9ce3141076cff4",
"_journal/2024-02/2024-02-23.md": "0aad297148e8cc4058b48b7e45787ca7",
"_journal/2024-02-25.md": "fb1a48208c11d12262facc647749ca6f",
@ -276,7 +278,12 @@
"_journal/2024-03/2024-03-15.md": "e54b2513beac5f46313b4c37622adf39",
"_journal/2024-03-17.md": "72e99c7630085aee2c7f340a06b5ada7",
"_journal/2024-03/2024-03-16.md": "ab7629c24ebe70838072cf6acec47cb0",
"encoding/floating-point.md": "6aa91498473ea5f8504dfa7f87bf77f4"
"encoding/floating-point.md": "6aa91498473ea5f8504dfa7f87bf77f4",
"_journal/2024-03-18.md": "8479f07f63136a4e16c9cd07dbf2f27f",
"_journal/2024-03/2024-03-17.md": "23f9672f5c93a6de52099b1b86834e8b",
"set/directed-graph.md": "b4b8ad1be634a0a808af125fe8577a53",
"set/index.md": "b82a215fbee3c576186fc1af93c82fcb",
"set/graphs.md": "938b5313e97eb364c97d752fdb262a52"
},
"fields_dict": {
"Basic": [

View File

@ -0,0 +1,15 @@
---
title: "2024-03-18"
---
- [x] Anki Flashcards
- [x] KoL
- [ ] Sheet Music (10 min.)
- [ ] Go (1 Life & Death Problem)
- [ ] Korean (Read 1 Story)
- [ ] Interview Prep (1 Practice Problem)
- [ ] Log Work Hours (Max 3 hours)
* Finished [buffer pool manager project](https://15445.courses.cs.cmu.edu/fall2022/project1/).
* Added notes on [[graphs|graph]]-related terminology. Updated "Introduction to Algorithms" to fourth edition.
* Watched [How My Student Became 1 Dan](https://www.youtube.com/watch?v=ZvHL_lwfYYI&t=595s).

View File

@ -18,7 +18,7 @@ Aux. Memory | $O(1)$
Basic
What precondition must the input of `BINARY_SEARCH` satisfy?
Back: It must already be sorted.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708781334247-->
END%%
@ -26,7 +26,7 @@ END%%
Basic
What is the best case running time of `BINARY_SEARCH`?
Back: $\Omega(1)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708117310004-->
END%%
@ -34,7 +34,7 @@ END%%
Basic
What input does `BINARY_SEARCH` perform best on?
Back: One in which the value being searched for is already in the middle.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708117310011-->
END%%
@ -42,7 +42,7 @@ END%%
Basic
What is the worst case running time of `BINARY_SEARCH`?
Back: $O(\lg{n})$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708117310015-->
END%%
@ -50,7 +50,7 @@ END%%
Basic
What input does `BINARY_SEARCH` perform worst on?
Back: One in which the value does not exist.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708117310018-->
END%%
@ -58,7 +58,7 @@ END%%
Basic
What is the typical output of `BINARY_SEARCH`?
Back: The index of the element in the array being searched for, if found.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708117310021-->
END%%
@ -108,7 +108,7 @@ int binary_search(const int needle, const int n, int A[static n]) {
Basic
In `BINARY_SEARCH`, when could using floor for midpoint calculations yield different answers than ceiling?
Back: When there exist duplicate members.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708174545522-->
END%%
@ -116,10 +116,10 @@ END%%
Basic
In `BINARY_SEARCH`, what ensures left pointer `L` and right pointers `R` eventually satisfy `L > R`?
Back: The found midpoint is always excluded from the next `BINARY_SEARCH` invocation.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708174545527-->
END%%
## References
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).

View File

@ -14,7 +14,7 @@ An **incremental** approach to algorithm design involves acting on a single elem
Basic
What does an incremental approach to algorithm design refer to?
Back: An algorithm that acts on a single element at a time.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467144-->
END%%
@ -22,7 +22,7 @@ END%%
Basic
What does a divide-and-conquer approach to algorithm design refer to?
Back: An algorithm that breaks a problem into similar but simpler subproblems.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467147-->
END%%
@ -30,7 +30,7 @@ END%%
Basic
What does it mean for a divide-and-conquer algorithm to "bottom out"?
Back: An input that cannot (or should not) be divided any further is encountered.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467151-->
END%%
@ -38,14 +38,14 @@ END%%
Basic
In the context of algorithms, what does a "sentinel" refer to?
Back: A special value used to simplify code.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467155-->
END%%
%%ANKI
Cloze
Insertion sort is to an {incremental} design approach whereas merge sort is to a {divide-and-conquer} design approach.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467159-->
END%%
@ -53,7 +53,7 @@ END%%
Basic
What ideas does the term "divide-and-conquer" invoke?
Back: Breaking a problem into subproblems that are easier to solve.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467164-->
END%%
@ -61,7 +61,7 @@ END%%
Basic
According to Cormen et al., what three steps do divide-and-conquer algorithms take?
Back: Divide, conquer, and combine.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467167-->
END%%
@ -69,7 +69,7 @@ END%%
Basic
What is the "divide" step of a divide-and-conquer algorithm?
Back: Breaking the problem into smaller instances of the same problem.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467172-->
END%%
@ -77,7 +77,7 @@ END%%
Basic
What is the "conquer" step of a divide-and-conquer algorithm?
Back: Solving subproblems recursively or, if small enough, in a straightforward manner.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467178-->
END%%
@ -85,7 +85,7 @@ END%%
Basic
What is the "combine" step of a divide-and-conquer algorithm?
Back: Manipulating solutions to smaller problems into a solution for the original problem.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467182-->
END%%
@ -93,10 +93,10 @@ END%%
Basic
What is a running time recurrence?
Back: A formula that describes overall running time in terms of running time on smaller inputs.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467187-->
END%%
## References
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).

View File

@ -21,7 +21,7 @@ A loop invariant $P$ is a condition that holds before, during, and after each it
Basic
What are the three necessary properties of a loop invariant?
Back: Initialization, maintenance, and termination.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707329732922-->
END%%
@ -29,7 +29,7 @@ END%%
Basic
What does it mean for loop invariant $P$ to respect initialization?
Back: $P$ is true before the first iteration of the loop.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707329732926-->
END%%
@ -37,7 +37,7 @@ END%%
Basic
What does it mean for loop invariant $P$ to respect maintenance?
Back: If $P$ is true before an iteration, $P$ is also true before the next iteration.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707329732928-->
END%%
@ -45,7 +45,7 @@ END%%
Basic
What does it mean for loop invariant $P$ to respect termination?
Back: $P$ provides a condition used to prove an algorithm's correctness.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707329732929-->
END%%
@ -56,7 +56,7 @@ At what point in the following should initialization of a loop invariant be chec
for (int i = 0; i < n; ++i) { ... }
```
Back: After `int i = 0` but before `i < n`.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
Tags: c17
<!--ID: 1707329732931-->
END%%
@ -66,14 +66,14 @@ Notice loop invariants mirror mathematical induction. Initialization is analogou
%%ANKI
Cloze
Loop invariants are to {initialization} whereas mathematical induction is to {a base case}.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707329951146-->
END%%
%%ANKI
Cloze
Loop invariants are to {maintenance} whereas mathematical induction is to {the inductive step}.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707329951148-->
END%%
@ -81,10 +81,10 @@ END%%
Basic
Which loop invariant property has no analogy to mathematical induction?
Back: Termination
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707329951150-->
END%%
## References
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ Adaptive | Yes
Basic
Describe `BUBBLE_SORT` in a single sentence.
Back: Repeatedly swap the smaller of adjacent records downward.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707589393196-->
END%%
@ -32,7 +32,7 @@ END%%
Basic
What is `BUBBLE_SORT`'s best case runtime?
Back: $\Omega(n)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634781-->
END%%
@ -40,7 +40,7 @@ END%%
Basic
How is it `BUBBLE_SORT` achieves best case linear runtime?
Back: By terminating when no swaps occurred on a given iteration.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634782-->
END%%
@ -48,7 +48,7 @@ END%%
Basic
What input value does `BUBBLE_SORT` perform best on?
Back: An already sorted array.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634784-->
END%%
@ -56,7 +56,7 @@ END%%
Basic
What is `BUBBLE_SORT`'s worst case runtime?
Back: $O(n^2)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634785-->
END%%
@ -64,7 +64,7 @@ END%%
Basic
What input value does `BUBBLE_SORT` perform worst on?
Back: An array in reverse-sorted order.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634787-->
END%%
@ -72,7 +72,7 @@ END%%
Basic
What is `BUBBLE_SORT`'s average case runtime?
Back: $O(n^2)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634788-->
END%%
@ -80,7 +80,7 @@ END%%
Basic
Is `BUBBLE_SORT` in place?
Back: Yes
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634789-->
END%%
@ -88,7 +88,7 @@ END%%
Basic
Is `BUBBLE_SORT` stable?
Back: Yes
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634791-->
END%%
@ -96,7 +96,7 @@ END%%
Basic
Is `BUBBLE_SORT` adaptive?
Back: Yes
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634792-->
END%%
@ -126,7 +126,7 @@ Basic
What sorting algorithm does the following demonstrate?
![[bubble-sort.gif]]
Back: `BUBBLE_SORT`
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634794-->
END%%
@ -149,7 +149,7 @@ We prove $P$ maintains the requisite properties:
Basic
Given array `A[0..n-1]`, what is `BUBBLE_SORT`'s loop invariant?
Back: `A[0..i-1]` is a sorted array of the `i` least elements of `A`.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634796-->
END%%
@ -157,7 +157,7 @@ END%%
Basic
What is initialization of `BUBBLE_SORT`'s loop invariant?
Back: Sorting starts with an empty array which is trivially sorted.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634797-->
END%%
@ -165,7 +165,7 @@ END%%
Basic
What is maintenance of `BUBBLE_SORT`'s loop invariant?
Back: Each iteration puts the next least element into the sorted subarray.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634798-->
END%%
@ -176,7 +176,7 @@ Back:
```
[ sorted | unsorted ]
```
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634800-->
END%%
@ -187,17 +187,17 @@ Which element will `BUBBLE_SORT` move to `sorted`?
[ sorted | unsorted ]
```
Back: The least element in `unsorted`.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634801-->
END%%
%%ANKI
Cloze
Selection sort makes fewer {swaps} than `BUBBLE_SORT` in the average case.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634803-->
END%%
## References
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).

View File

@ -24,7 +24,7 @@ Adaptive | Yes
Basic
Describe `INSERTION_SORT` in a single sentence.
Back: Repeatedly put the next record into a sorted array from right to left.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707589393194-->
END%%
@ -32,7 +32,7 @@ END%%
Basic
What is `INSERTION_SORT`'s best case runtime?
Back: $\Omega(n)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1706925879541-->
END%%
@ -40,7 +40,7 @@ END%%
Basic
What input value does `INSERTION_SORT` perform best on?
Back: An already sorted array.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1706925921544-->
END%%
@ -48,7 +48,7 @@ END%%
Basic
What is `INSERTION_SORT`'s worst case runtime?
Back: $O(n^2)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1706926586947-->
END%%
@ -56,7 +56,7 @@ END%%
Basic
What input value does `INSERTION_SORT` perform worst on?
Back: An array in reverse-sorted order.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1706926586951-->
END%%
@ -64,7 +64,7 @@ END%%
Basic
What is `INSERTION_SORT`'s average case runtime?
Back: $O(n^2)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707329732933-->
END%%
@ -72,7 +72,7 @@ END%%
Basic
Is `INSERTION_SORT` in place?
Back: Yes
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1706926586955-->
END%%
@ -80,7 +80,7 @@ END%%
Basic
Is `INSERTION_SORT` stable?
Back: Yes
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1706926586959-->
END%%
@ -88,7 +88,7 @@ END%%
Basic
Is `INSERTION_SORT` adaptive?
Back: Yes
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634779-->
END%%
@ -110,7 +110,7 @@ Basic
What sorting algorithm does the following demonstrate?
![[insertion-sort.gif]]
Back: `INSERTION_SORT`
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707400559085-->
END%%
@ -140,7 +140,7 @@ END%%
Basic
What is initialization of `INSERTION_SORT`'s loop invariant?
Back: Sorting starts with an singleton array which is trivially sorted.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707332638373-->
END%%
@ -148,14 +148,14 @@ END%%
Basic
What is maintenance of `INSERTION_SORT`'s loop invariant?
Back: Each iteration puts the current element into sorted order.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707332638375-->
END%%
%%ANKI
Cloze
`INSERTION_SORT` makes fewer {comparisons} than `SELECTION_SORT` in the average case.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708002185982-->
END%%
@ -169,7 +169,7 @@ If you repeat this process for every card in the deck, your left hand will event
Basic
What analogy does Cormen et al. use to explain `INSERTION_SORT`?
Back: Sorting a shuffled deck of playing cards.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1706927594729-->
END%%
@ -177,7 +177,7 @@ END%%
Basic
What invariant does the left hand maintain in Cormen et al.'s `INSERTION_SORT` analogy?
Back: It contains all drawn cards in sorted order.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1706927594732-->
END%%
@ -188,7 +188,7 @@ Back:
```
[ sorted | unsorted ]
```
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707399790957-->
END%%
@ -199,7 +199,7 @@ How many comparisons does `INSERTION_SORT` typically perform with `x`?
[ sorted | x : unsorted ]
```
Back: One plus however many elements in `sorted` are greater than `x`.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707399790958-->
END%%
@ -210,10 +210,10 @@ Which element will `INSERTION_SORT` move to `sorted`?
[ sorted | unsorted ]
```
Back: The first element of `unsorted`.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707399790960-->
END%%
## References
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).

View File

@ -24,7 +24,7 @@ Adaptive | -
Basic
What does the term "merge" in `MERGE_SORT` refer to?
Back: The primary operation used to combine array halves.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467101-->
END%%
@ -32,7 +32,7 @@ END%%
Basic
What is `MERGE_SORT`'s best case runtime?
Back: $\Omega(n\lg{n})$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467109-->
END%%
@ -40,7 +40,7 @@ END%%
Basic
What is `MERGE_SORT`'s worst case runtime?
Back: $O(n\lg{n})$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467112-->
END%%
@ -48,7 +48,7 @@ END%%
Basic
What is `MERGE_SORT`'s average case runtime?
Back: $O(n\lg{n})$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467115-->
END%%
@ -56,7 +56,7 @@ END%%
Basic
What is the "divide" step of `MERGE_SORT`?
Back: Divide the input array into two subarrays of half size.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467118-->
END%%
@ -64,7 +64,7 @@ END%%
Basic
What is the "conquer" step of `MERGE_SORT`?
Back: Call `MERGE_SORT` on the "divide"-step's two subarrays.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467121-->
END%%
@ -72,7 +72,7 @@ END%%
Basic
What is the "combine" step of `MERGE_SORT`?
Back: Merge the sorted subarrays produced by the "conquer" step.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467125-->
END%%
@ -80,7 +80,7 @@ END%%
Basic
When does `MERGE_SORT` "bottom out"?
Back: When the sequence to be sorted has length 1 or less.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467133-->
END%%
@ -130,7 +130,7 @@ void merge_sort(int i, int j, int *A) {
Basic
Where in `MERGE_SORT`'s implementation are sentinels useful?
Back: As the last elements of the two arrays to combine.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467137-->
END%%
@ -138,7 +138,7 @@ END%%
Basic
What sentinel values are typically used in `MERGE_SORT`'s "merge" operation?
Back: $\infty$ or the record type's equivalent.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742467141-->
END%%
@ -147,10 +147,10 @@ Basic
What sorting algorithm does the following demonstrate?
![[merge-sort.gif]]
Back: `MERGE_SORT`
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708742590435-->
END%%
## References
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).

View File

@ -25,7 +25,7 @@ Adaptive | No
Basic
Describe `SELECTION_SORT` in a single sentence.
Back: Repeatedly put the smallest unsorted record at the end of a sorted array.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707589393190-->
END%%
@ -33,7 +33,7 @@ END%%
Basic
What is `SELECTION_SORT`'s best case runtime?
Back: $\Omega(n^2)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707398773323-->
END%%
@ -41,7 +41,7 @@ END%%
Basic
What is `SELECTION_SORT`'s worst case runtime?
Back: $O(n^2)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707398773326-->
END%%
@ -49,7 +49,7 @@ END%%
Basic
What is `SELECTION_SORT`'s average case runtime?
Back: $O(n^2)$
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707398773327-->
END%%
@ -57,7 +57,7 @@ END%%
Basic
Is `SELECTION_SORT` in place?
Back: Yes
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707398773328-->
END%%
@ -65,7 +65,7 @@ END%%
Basic
Is `SELECTION_SORT` stable?
Back: No
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707398773330-->
END%%
@ -73,7 +73,7 @@ END%%
Basic
Is `SELECTION_SORT` adaptive?
Back: No
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707504634778-->
END%%
@ -102,7 +102,7 @@ Basic
What sorting algorithm does the following demonstrate?
![[selection-sort.gif]]
Back: `SELECTION_SORT`
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707400943836-->
END%%
@ -125,7 +125,7 @@ We prove $P$ maintains the requisite properties:
Basic
Given array `A[0..n-1]`, what is `SELECTION_SORT`'s loop invariant?
Back: `A[0..i-1]` is a sorted array of the `i` least elements of `A`.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707398773331-->
END%%
@ -133,7 +133,7 @@ END%%
Basic
What is initialization of `SELECTION_SORT`'s loop invariant?
Back: Sorting starts with an empty array which is trivially sorted.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707398773333-->
END%%
@ -141,7 +141,7 @@ END%%
Basic
What is maintenance of `SELECTION_SORT`'s loop invariant?
Back: Each iteration puts the next least element into the sorted subarray.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707398773334-->
END%%
@ -152,7 +152,7 @@ Back:
```
[ sorted | unsorted ]
```
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707399790952-->
END%%
@ -163,17 +163,17 @@ Which element will `SELECTION_SORT` move to `sorted`?
[ sorted | unsorted ]
```
Back: The least element in `unsorted`.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1707399790955-->
END%%
%%ANKI
Cloze
`SELECTION_SORT` makes fewer {swaps} than `INSERTION_SORT` in the average case.
Reference: Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
<!--ID: 1708002177782-->
END%%
## References
* Thomas H. Cormen et al., *Introduction to Algorithms*, 3rd ed (Cambridge, Mass: MIT Press, 2009).
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).

View File

@ -31,15 +31,6 @@ Reference: Brian W. Kernighan and Dennis M. Ritchie, *The C Programming Language
<!--ID: 1706975891810-->
END%%
%%ANKI
Basic
What alternative does Lua provide to C's `\ooo` sequence?
Back: `\ddd`, a *decimal* escape sequence.
Reference: Roberto Ierusalimschy, _Programming in Lua_, Fourth edition (Rio de Janeiro: Lua.org, 2016).
Tags: lua
<!--ID: 1706975891813-->
END%%
%%ANKI
Basic
How are C escape sequences exposed in bash?

View File

@ -1,5 +0,0 @@
---
title: Lua
tags:
- lua
---

1048
notes/set/graphs.md Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

7
notes/set/index.md Normal file
View File

@ -0,0 +1,7 @@
---
title: Set
TARGET DECK: Obsidian::STEM
FILE TAGS: set
tags:
- set
---