Intrusive containers and graph isomorphisms.
parent
5f8017ba3d
commit
48a4f9127f
|
@ -123,7 +123,8 @@
|
||||||
"array-1d-row-major.png",
|
"array-1d-row-major.png",
|
||||||
"array-1d-col-major.png",
|
"array-1d-col-major.png",
|
||||||
"array-multi-row-major.png",
|
"array-multi-row-major.png",
|
||||||
"array-multi-col-major.png"
|
"array-multi-col-major.png",
|
||||||
|
"graph-isomorphic.png"
|
||||||
],
|
],
|
||||||
"File Hashes": {
|
"File Hashes": {
|
||||||
"algorithms/index.md": "3ac071354e55242919cc574eb43de6f8",
|
"algorithms/index.md": "3ac071354e55242919cc574eb43de6f8",
|
||||||
|
@ -304,7 +305,7 @@
|
||||||
"_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": "f2e907b2643cd4e5023169dcd96ca828",
|
"set/index.md": "f2e907b2643cd4e5023169dcd96ca828",
|
||||||
"set/graphs.md": "242195a7af5dc5dfefdc07ccba8b0fa4",
|
"set/graphs.md": "51f1346e7c0e13daaa2cc9ce816bd1e0",
|
||||||
"_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb",
|
"_journal/2024-03-19.md": "a0807691819725bf44c0262405e97cbb",
|
||||||
"_journal/2024-03/2024-03-18.md": "63c3c843fc6cfc2cd289ac8b7b108391",
|
"_journal/2024-03/2024-03-18.md": "63c3c843fc6cfc2cd289ac8b7b108391",
|
||||||
"awk/variables.md": "e40a20545358228319f789243d8b9f77",
|
"awk/variables.md": "e40a20545358228319f789243d8b9f77",
|
||||||
|
@ -400,7 +401,7 @@
|
||||||
"_journal/2024-05-01.md": "959ff67fe3db585ba6a7b121d853bbac",
|
"_journal/2024-05-01.md": "959ff67fe3db585ba6a7b121d853bbac",
|
||||||
"_journal/2024-05-02.md": "d7d6ba7e065d807986f0bd77281c0bb1",
|
"_journal/2024-05-02.md": "d7d6ba7e065d807986f0bd77281c0bb1",
|
||||||
"data-structures/priority-queues.md": "8c5c6bf62b1a39d8f1f72b800fcb17ff",
|
"data-structures/priority-queues.md": "8c5c6bf62b1a39d8f1f72b800fcb17ff",
|
||||||
"data-structures/heaps.md": "0cba4acb7667dcab80fa4e7778e86cc8",
|
"data-structures/heaps.md": "0317372dcae8d81e4345c3ffa5c0cf90",
|
||||||
"data-structures/index.md": "2605977fad54956b5dc2d8dda9be2b10",
|
"data-structures/index.md": "2605977fad54956b5dc2d8dda9be2b10",
|
||||||
"abstract-data-types/priority-queues.md": "d3dad736cb05c47bdc93c52a3a4af083",
|
"abstract-data-types/priority-queues.md": "d3dad736cb05c47bdc93c52a3a4af083",
|
||||||
"abstract-data-types/index.md": "6b110b20393c561497629ca4c3e09472",
|
"abstract-data-types/index.md": "6b110b20393c561497629ca4c3e09472",
|
||||||
|
@ -411,17 +412,18 @@
|
||||||
"_journal/2024-04/2024-04-30.md": "369f98b9d91de89cc1f4f581bc530c0d",
|
"_journal/2024-04/2024-04-30.md": "369f98b9d91de89cc1f4f581bc530c0d",
|
||||||
"_journal/2024-05-06.md": "bc9306348b7063b87741768391d9d8a7",
|
"_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",
|
"data-structures/intrusive.md": "e43c435136c5de92a094e4e49af9f436",
|
||||||
|
"data-structures/linked-lists.md": "a68e7709791e449bee7875ad9680dd96",
|
||||||
|
"data-structures/arrays.md": "bb6b8609d16f9f2565d5238c0f9b8566",
|
||||||
|
"abstract-data-types/stacks.md": "d4324db19a88211dc6bf4f0e56c74cec",
|
||||||
|
"abstract-data-types/queues.md": "db668234b6c6051635321730b7176dcb",
|
||||||
|
"_journal/2024-05-12.md": "46f68b2a55e3b4948d90c70009b325d8",
|
||||||
|
"_journal/2024-05/2024-05-11.md": "f80bb3f8ca9cad70a2016224c6a44734",
|
||||||
|
"_journal/2024-05/2024-05-10.md": "ae2d0ac5b24d3b8e55b691894d852324",
|
||||||
|
"_journal/2024-05/2024-05-09.md": "2339530b1654a2e8e96d908ecb91b8d1",
|
||||||
"_journal/2024-05/2024-05-08.md": "0f1b1b9e2abcf3203b511b9e034e86f4",
|
"_journal/2024-05/2024-05-08.md": "0f1b1b9e2abcf3203b511b9e034e86f4",
|
||||||
"_journal/2024-05/2024-05-07.md": "4b1dde039a251f9a6dc7e606de98616d",
|
"_journal/2024-05/2024-05-07.md": "4b1dde039a251f9a6dc7e606de98616d",
|
||||||
"_journal/2024-05/2024-05-06.md": "bc9306348b7063b87741768391d9d8a7",
|
"_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": {
|
"fields_dict": {
|
||||||
"Basic": [
|
"Basic": [
|
||||||
|
|
|
@ -7,3 +7,6 @@ title: "2024-05-12"
|
||||||
- [ ] Sheet Music (10 min.)
|
- [ ] Sheet Music (10 min.)
|
||||||
- [ ] Go (1 Life & Death Problem)
|
- [ ] Go (1 Life & Death Problem)
|
||||||
- [ ] Korean (Read 1 Story)
|
- [ ] Korean (Read 1 Story)
|
||||||
|
|
||||||
|
* Notes on linked lists and intrusive/non-intrusive data structures.
|
||||||
|
* Notes on graphs/isomorphisms.
|
|
@ -65,6 +65,36 @@ Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (
|
||||||
<!--ID: 1715460959188-->
|
<!--ID: 1715460959188-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {head} of an array refers to {its first element}.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735208-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {tail} of an array refers to {all but its first element}.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735211-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the runtime of prepending an element to a large enough array?
|
||||||
|
Back: $O(n)$
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735214-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the runtime of finding the $k$th element of an array?
|
||||||
|
Back: $O(1)$
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735217-->
|
||||||
|
END%%
|
||||||
|
|
||||||
## Bibliography
|
## Bibliography
|
||||||
|
|
||||||
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
|
@ -0,0 +1,219 @@
|
||||||
|
---
|
||||||
|
title: Intrusive Containers
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: data_structure::intrusive
|
||||||
|
tags:
|
||||||
|
- data_structure
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
An intrusive container is a data structure used to hold a collection of objects in which membership bookkeeping is stored in the objects themselves rather than a separate structure. For example, consider the following `struct`:
|
||||||
|
|
||||||
|
```c
|
||||||
|
struct Point {
|
||||||
|
float x, y;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
A non-intrusive implementation of a [[linked-lists|doubly linked list]] would look as follows:
|
||||||
|
|
||||||
|
```c
|
||||||
|
struct ListNode {
|
||||||
|
struct Point val;
|
||||||
|
struct ListNode *next, *prev;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
An intrusive implementation would instead modify `Point` like so:
|
||||||
|
|
||||||
|
```c
|
||||||
|
struct Point {
|
||||||
|
float x, y;
|
||||||
|
struct Point *next, *prev;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is an intrusive container?
|
||||||
|
Back: A collection of objects in which membership bookkeeping is stored in the objects themselves.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735123-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the opposite of an "intrusive container"?
|
||||||
|
Back: A non-intrusive container.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735129-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Given the following `struct`, implement an intrusive doubly linked list.
|
||||||
|
```c
|
||||||
|
struct Point {
|
||||||
|
float x, y;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
struct Point {
|
||||||
|
float x, y;
|
||||||
|
struct Point *next, *prev;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
Tags: c17 data_structure::linked_list
|
||||||
|
<!--ID: 1715534735133-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Is the following considered an intrusive container or non-intrusive container?
|
||||||
|
```c
|
||||||
|
struct Point {
|
||||||
|
float x, y;
|
||||||
|
struct Point *next, *prev;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back: Intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
Tags: c17 data_structure::linked_list
|
||||||
|
<!--ID: 1715534821493-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Is the following considered an intrusive container or non-intrusive container?
|
||||||
|
```c
|
||||||
|
struct ListNode {
|
||||||
|
struct Point val;
|
||||||
|
struct ListNode *next, *prev;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back: Non-intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534821498-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Given the following `struct`, implement a non-intrusive doubly linked list.
|
||||||
|
```c
|
||||||
|
struct Point {
|
||||||
|
float x, y;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back:
|
||||||
|
```c
|
||||||
|
struct ListNode {
|
||||||
|
struct Point val;
|
||||||
|
struct ListNode *next, *prev;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
Tags: c17 data_structure::linked_list
|
||||||
|
<!--ID: 1715534735137-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Given the following `struct`, how many linked lists can a `Point` exist in?
|
||||||
|
```c
|
||||||
|
struct Point {
|
||||||
|
float x, y;
|
||||||
|
struct Point *next, *prev;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back: Zero or one.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
Tags: c17 data_structure::linked_list
|
||||||
|
<!--ID: 1715534735140-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Given the following `struct`, how many linked lists can a `Point` exist in?
|
||||||
|
```c
|
||||||
|
struct ListNode {
|
||||||
|
struct Point *val;
|
||||||
|
struct ListNode *next, *prev;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Back: Zero or more.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
Tags: c17 data_structure::linked_list
|
||||||
|
<!--ID: 1715534735143-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of intrusive or non-intrusive containers allow a `struct` to exist in an arbitrary number of linked lists?
|
||||||
|
Back: Non-intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
Tags: data_structure::linked_list
|
||||||
|
<!--ID: 1715534735146-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of intrusive or non-intrusive containers perform more allocations?
|
||||||
|
Back: Non-intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735149-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of intrusive or non-intrusive containers perform more de-allocations?
|
||||||
|
Back: Non-intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735152-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of intrusive or non-intrusive containers has better spatial locality?
|
||||||
|
Back: Intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735155-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of intrusive or non-intrusive containers avoid modifying object definitions?
|
||||||
|
Back: Non-intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735158-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of intrusive or non-intrusive containers allow implicitly finding *all* containers an object is contained in?
|
||||||
|
Back: Intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735161-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of intrusive or non-intrusive containers cannot be used for opaque types?
|
||||||
|
Back: Intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735164-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Which of intrusive or non-intrusive containers requires searching in each container for the same reference?
|
||||||
|
Back: Non-intrusive.
|
||||||
|
Reference: Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
||||||
|
<!--ID: 1715534735167-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Bibliography
|
||||||
|
|
||||||
|
* Fuchsia. “Introduction to Fbl Intrusive Containers.” Accessed May 12, 2024. [https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction](https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/fbl_containers_guide/introduction).
|
|
@ -0,0 +1,108 @@
|
||||||
|
---
|
||||||
|
title: Linked Lists
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: data_structure::linked_list
|
||||||
|
tags:
|
||||||
|
- data_structure
|
||||||
|
- linked_list
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does it mean for a linked list to be singly linked?
|
||||||
|
Back: Each entry in the list has a `next` pointer only.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735171-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What condition is used to check if a singly linked list is empty?
|
||||||
|
Back: Its empty if the head of the list is `NIL`.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735173-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {head} of a linked list refers to {its first element}.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735177-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
The {tail} of a linked list refers to {its last element}.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735180-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does it mean for a singly linked list to be circular?
|
||||||
|
Back: The tail points to the head.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735184-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the runtime of inserting an element at the front of a singly linked list?
|
||||||
|
Back: $O(1)$
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735187-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the runtime of finding the $k$th element of a singly linked list?
|
||||||
|
Back: $O(n)$
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735190-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does it mean for a linked list to be doubly linked?
|
||||||
|
Back: Each entry in the list have `next` and `prev` pointers.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735193-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What condition is used to check if a doubly linked list is empty?
|
||||||
|
Back: Its empty if the head of the list is `NIL`.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735196-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does it mean for a doubly linked list to be circular?
|
||||||
|
Back: The tail points to the head, and the head points to the tail.
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735199-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the runtime of prepending an element to a doubly linked list?
|
||||||
|
Back: $O(1)$
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735202-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the runtime of finding the $k$th element of a doubly linked list?
|
||||||
|
Back: $O(n)$
|
||||||
|
Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
||||||
|
<!--ID: 1715534735205-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## Bibliography
|
||||||
|
|
||||||
|
* Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
|
@ -1020,6 +1020,129 @@ Reference: Thomas H. Cormen et al., Introduction to Algorithms, Fourth edition (
|
||||||
<!--ID: 1710807788538-->
|
<!--ID: 1710807788538-->
|
||||||
END%%
|
END%%
|
||||||
|
|
||||||
|
## Isomorphisms
|
||||||
|
|
||||||
|
An **isomorphism** between two graphs $G_1$ and $G_2$ is a bijection $f \colon V_1 \rightarrow V_2$ between the vertices of the graphs such that $(a, b)$ is an edge in $G_1$ if and only if $(f(a), f(b))$ is an edge in $G_2$. Here parenthesis are used to denote either ordered pairs (for directed graphs) or unordered pairs (for undirected graphs).
|
||||||
|
|
||||||
|
We say $G_1$ and $G_2$ are **isomorphic**, denoted $G_1 \cong G_2$, if and only if there exists an isomorphism between $G_1$ and $G_2$.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What kind of mathematical object is an isomorphism between graphs?
|
||||||
|
Back: A function.
|
||||||
|
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: 1715537560168-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What *kind* of function is an isomorphism between two graphs?
|
||||||
|
Back: A bijective function.
|
||||||
|
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: 1715537560173-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What *is* an isomorphism between graphs $G_1 = (V_1, E_1)$ and $G_2 = (V_2, E_2)$?
|
||||||
|
Back: A bijection $f \colon V_1 \rightarrow V_2$ such that $(a, b) \in E_1$ if and only if $(f(a), f(b)) \in E_2$.
|
||||||
|
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: 1715537560176-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the domain of an isomorphism between graphs $G_1 = (V_1, E_1)$ and $G_2 = (V_2, E_2)$?
|
||||||
|
Back: $V_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: 1715537560179-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the codomain of an isomorphism between graphs $G_1 = (V_1, E_1)$ and $G_2 = (V_2, E_2)$?
|
||||||
|
Back: $V_2$.
|
||||||
|
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: 1715537560183-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the edge relation of isomorphism $f$ between graphs $G_1 = (V_1, E_1)$ and $G_2 = (V_2, E_2)$?
|
||||||
|
Back: $(a, b) \in E_1$ if and only if $(f(a), f(b)) \in E_2$.
|
||||||
|
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: 1715537560186-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does it mean for graphs $G_1$ and $G_2$ to be isomorphic?
|
||||||
|
Back: There exists an isomorphism between them.
|
||||||
|
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: 1715537560190-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
If two graphs are equal, are they isomorphic?
|
||||||
|
Back: Yes.
|
||||||
|
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: 1715537560195-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
If two graphs are isomorphic, are they equal?
|
||||||
|
Back: Not necessarily.
|
||||||
|
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: 1715537560199-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Are the following two graphs equal?
|
||||||
|
![[graph-isomorphic.png]]
|
||||||
|
Back: No.
|
||||||
|
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: 1715537560203-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Are the following two graphs isomorphic?
|
||||||
|
![[graph-isomorphic.png]]
|
||||||
|
Back: Yes.
|
||||||
|
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: 1715537560207-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
If the following graphs are isomorphic, what is the domain of the isomorphism?
|
||||||
|
![[graph-isomorphic.png]]
|
||||||
|
Back: $\{a, b, c\}$.
|
||||||
|
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: 1715537560210-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
If the following graphs are isomorphic, what is the codomain of the isomorphism?
|
||||||
|
![[graph-isomorphic.png]]
|
||||||
|
Back: $\{u, v, w\}$.
|
||||||
|
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: 1715537560214-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does it mean for two graphs to be equal?
|
||||||
|
Back: Two graphs are equal if their vertex and edge sets are equal.
|
||||||
|
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: 1715537560218-->
|
||||||
|
END%%
|
||||||
|
|
||||||
## Bibliography
|
## Bibliography
|
||||||
|
|
||||||
|
* 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).
|
||||||
* Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
* Thomas H. Cormen et al., _Introduction to Algorithms_, Fourth edition (Cambridge, Massachusett: The MIT Press, 2022).
|
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
Reference in New Issue