Notes on permutations and combinations.
parent
2a2d8f8195
commit
4fe3a60534
|
@ -124,7 +124,7 @@
|
||||||
"algorithms/sorting/selection-sort.md": "fcd0dc2ebaabd0a4db1baf7e7ef9f7a9",
|
"algorithms/sorting/selection-sort.md": "fcd0dc2ebaabd0a4db1baf7e7ef9f7a9",
|
||||||
"algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97",
|
"algorithms/index 1.md": "6fada1f3d5d3af64687719eb465a5b97",
|
||||||
"binary/hexadecimal.md": "c3d485f1fd869fe600334ecbef7d5d70",
|
"binary/hexadecimal.md": "c3d485f1fd869fe600334ecbef7d5d70",
|
||||||
"binary/index.md": "27bdd4423e323cd961ddb307ab28d977",
|
"binary/index.md": "b4db8fe8ae874a682a5acf81271e303b",
|
||||||
"_journal/2024-02-09.md": "a798d35f0b2bd1da130f7ac766166109",
|
"_journal/2024-02-09.md": "a798d35f0b2bd1da130f7ac766166109",
|
||||||
"c/types.md": "cf3e66e5aee58a94db3fdf0783908555",
|
"c/types.md": "cf3e66e5aee58a94db3fdf0783908555",
|
||||||
"logic/quantification.md": "5d7579a511e9ff683edeec62bcc291b8",
|
"logic/quantification.md": "5d7579a511e9ff683edeec62bcc291b8",
|
||||||
|
@ -171,10 +171,12 @@
|
||||||
"combinatorics/index.md": "f9de9671fdb6068ef2bb5e63051734be",
|
"combinatorics/index.md": "f9de9671fdb6068ef2bb5e63051734be",
|
||||||
"_journal/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629",
|
"_journal/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629",
|
||||||
"_journal/2024-02/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048",
|
"_journal/2024-02/2024-02-17.md": "7c37cb10515ed3d2f5388eaf02a67048",
|
||||||
"combinatorics/multiplicative-principle.md": "aec83fc4bafad4ae17bd3b4e92e068a1",
|
"combinatorics/multiplicative-principle.md": "3e4f600f5300d3d4d64099b8f2bd1458",
|
||||||
"combinatorics/additive-principle.md": "99320b513f16ef6be62bf766cfbd328d",
|
"combinatorics/additive-principle.md": "84dcd0243263b3c53456086ae43fa00f",
|
||||||
"_journal/2024-02-19.md": "77ade15d43f3fba69bde96d0e062ec13",
|
"_journal/2024-02-19.md": "87d762a68e9b8e3c7de0f02d651b1101",
|
||||||
"_journal/2024-02/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629"
|
"_journal/2024-02/2024-02-18.md": "67e36dbbb2cac699d4533b5a2eaeb629",
|
||||||
|
"combinatorics/permutations.md": "3c76f548e22f7271280b9ed82ae584ec",
|
||||||
|
"combinatorics/combinations.md": "0fb5351d4b0ab6c7c8cd17d9423d3dfa"
|
||||||
},
|
},
|
||||||
"fields_dict": {
|
"fields_dict": {
|
||||||
"Basic": [
|
"Basic": [
|
||||||
|
|
|
@ -9,3 +9,5 @@ title: "2024-02-19"
|
||||||
- [ ] Korean (Read 1 Story)
|
- [ ] Korean (Read 1 Story)
|
||||||
- [ ] Interview Prep (1 Practice Problem)
|
- [ ] Interview Prep (1 Practice Problem)
|
||||||
- [ ] Log Work Hours (Max 3 hours)
|
- [ ] Log Work Hours (Max 3 hours)
|
||||||
|
|
||||||
|
* Start encoding notes on permutations and combinations, as well as their relationship to one another.
|
|
@ -6,6 +6,46 @@ tags:
|
||||||
- binary
|
- binary
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
A binary digit or **bit** is a `0` or `1` character. A bit string is then a contiguous sequence of bits. It's **weight** is a reference to the number of `1`s in the bit string. Compare the below operation to the method for converting from one numerical base to another (e.g. [[hexadecimal]]).
|
||||||
|
|
||||||
|
```c
|
||||||
|
unsigned int bit_weight(int64_t n) {
|
||||||
|
unsigned int count = 0;
|
||||||
|
while (n) {
|
||||||
|
count += (n % 2 == 0) ? 0 : 1;
|
||||||
|
n /= 2;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
Why is a "bit" named the way it is?
|
||||||
|
Back: It is short for **b**inary dig**it**.
|
||||||
|
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: 1707432641557-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does the weight of a bit string refer to?
|
||||||
|
Back: The number of `1`s in the string.
|
||||||
|
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: 1708366788645-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How might you use C to find the weight of a bit string?
|
||||||
|
Back: Repeatedly divide by `2`, counting all remainders of `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).
|
||||||
|
Tags: c
|
||||||
|
<!--ID: 1708366788648-->
|
||||||
|
END%%
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Cloze
|
Cloze
|
||||||
A byte consists of {8} bits.
|
A byte consists of {8} bits.
|
||||||
|
|
|
@ -4,12 +4,15 @@ TARGET DECK: Obsidian::STEM
|
||||||
FILE TAGS: combinatorics set
|
FILE TAGS: combinatorics set
|
||||||
tags:
|
tags:
|
||||||
- combinatorics
|
- combinatorics
|
||||||
|
- set
|
||||||
---
|
---
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
The **additive principle** states that two finite and disjoint sets $A$ and $B$ satisfy $$|A \cup B| = |A| + |B|$$
|
The **additive principle** states that two finite and disjoint sets $A$ and $B$ satisfy $$|A \cup B| = |A| + |B|$$
|
||||||
|
|
||||||
|
This can be generalized to any number of finite and disjoint sets in the obvious way.
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What does the additive principle state?
|
What does the additive principle state?
|
||||||
|
|
|
@ -0,0 +1,189 @@
|
||||||
|
---
|
||||||
|
title: Combinations
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: combinatorics set
|
||||||
|
tags:
|
||||||
|
- combinatorics
|
||||||
|
- set
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
A $k$-**combination** of $n$ objects is an unordered "choice" of $k$ objects from the collection of $n$ objects. Alternatively viewed, it is a set of $k$ objects - ordering within a set does not matter. Combinations are derived by considering the number of $k$-[[permutations]] of $n$ objects and discarding order, i.e. dividing by $k!$. $$\binom{n}{k} = \frac{(n)_k}{k!} = \frac{n!}{k!(n - k)!}$$
|
||||||
|
|
||||||
|
```c
|
||||||
|
void combinations_aux(
|
||||||
|
const int i, const int n,
|
||||||
|
const int j, const int k,
|
||||||
|
int A[static n],
|
||||||
|
int res[static k]
|
||||||
|
) {
|
||||||
|
if (j == k) {
|
||||||
|
for (int m = 0; m < k; ++m) {
|
||||||
|
printf("%d ", A[res[m]]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return
|
||||||
|
} else if (n - i < k - j) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res[j] = A[i];
|
||||||
|
combinations_aux(i + 1, n, j + 1, k, A, res);
|
||||||
|
combinations_aux(i + 1, n, j, k, A, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
void combinations(const int n, const int k, int A[static n]) {
|
||||||
|
int *res = malloc(sizeof(int) * k);
|
||||||
|
combinations_aux(0, n, 0, k, A, res);
|
||||||
|
free(res);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The above approach prints out all $k$-combinations of a given array.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What *is* a combination?
|
||||||
|
Back: An unordered collection of objects.
|
||||||
|
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: 1708368078673-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
{1:Permutations} are to {2:tuples} as {2:combinations} are to {1:sets}.
|
||||||
|
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: 1708368078679-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is a $k$-combination expressed recursively?
|
||||||
|
Back: Include or exclude a candidate, then find $(k - 1)$- or $k$-combinations on the remainder.
|
||||||
|
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: 1708369553051-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is a $k$-combination of $n$ objects denoted?
|
||||||
|
Back: $\binom{n}{k}$
|
||||||
|
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: 1708368078685-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is $\binom{n}{k}$ pronounced?
|
||||||
|
Back: "$n$ choose $k$"
|
||||||
|
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: 1708368078690-->
|
||||||
|
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.
|
||||||
|
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%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is the closed formula of $\binom{n}{k}$ written in terms of factorials (*not* falling factorials)?
|
||||||
|
Back: $$\binom{n}{k} = \frac{n!}{k!(n - k)!}$$
|
||||||
|
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: 1708368078700-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How do $k$-permutations of $n$ objects relate to $k$-combinations?
|
||||||
|
Back: The number of $k$-combinations is the number of $k$-permutations divided by $k!$.
|
||||||
|
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: 1708368078705-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is the closed formula of $\binom{n}{k}$ written in terms of falling factorials?
|
||||||
|
Back: $$\binom{n}{k} = \frac{(n)_k}{k!}$$
|
||||||
|
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: 1708368078711-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What combinatorial concept explains the number of subsets of a finite set?
|
||||||
|
Back: Combinations.
|
||||||
|
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: 1708368078717-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How many subsets of $\{a, b, c, d, e\}$ have exactly $3$ members?
|
||||||
|
Back: $\binom{5}{3}$
|
||||||
|
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: 1708368078723-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
*Why* are binomial coefficients "symmetric"
|
||||||
|
Back: The number of ways to choose $k$ objects is the same as the number of ways to *not* choose those $k$ objects.
|
||||||
|
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: 1708368078729-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What value of $k \neq 1$ makes $\binom{n}{1} = \binom{n}{k}$?
|
||||||
|
Back: $n - 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: 1708368078735-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does $\binom{n}{0}$ evaluate to?
|
||||||
|
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: 1708368078740-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does $\binom{n}{n}$ evaluate to?
|
||||||
|
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: 1708368078746-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What term describes e.g. $\binom{n}{1}$, $\binom{n}{2}$, etc.?
|
||||||
|
Back: The binomial coefficients.
|
||||||
|
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: 1708368078753-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is a binomial?
|
||||||
|
Back: A polynomial containing two terms.
|
||||||
|
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: 1708368078759-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What are binomial coefficients?
|
||||||
|
The coefficients of terms in the expansion of a binomial, e.g. $(x + y)^n$.
|
||||||
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
|
<!--ID: 1708368078764-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
* 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).
|
|
@ -11,6 +11,8 @@ tags:
|
||||||
|
|
||||||
The **multiplicative principle** states that two finite sets $A$ and $B$ satisfy $$|A \times B| = |A| \cdot |B|$$
|
The **multiplicative principle** states that two finite sets $A$ and $B$ satisfy $$|A \times B| = |A| \cdot |B|$$
|
||||||
|
|
||||||
|
This can be generalized to any number of finite sets in the obvious way.
|
||||||
|
|
||||||
%%ANKI
|
%%ANKI
|
||||||
Basic
|
Basic
|
||||||
What does the multiplicative principle state?
|
What does the multiplicative principle state?
|
||||||
|
|
|
@ -0,0 +1,247 @@
|
||||||
|
---
|
||||||
|
title: Permutations
|
||||||
|
TARGET DECK: Obsidian::STEM
|
||||||
|
FILE TAGS: combinatorics set
|
||||||
|
tags:
|
||||||
|
- combinatorics
|
||||||
|
- set
|
||||||
|
---
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
A **permutation** of some $n$ objects is a (possible) rearrangement of those $n$ objects. The number of permutations is $n!$ since there are $n$ possible ways to pick the first object, $(n - 1)$ possible ways to pick the second, and so on.
|
||||||
|
|
||||||
|
```c
|
||||||
|
void permutations_aux(
|
||||||
|
const size_t n,
|
||||||
|
int A[static n],
|
||||||
|
int res[static n],
|
||||||
|
uint64_t choices
|
||||||
|
) {
|
||||||
|
if (!choices) {
|
||||||
|
for (size_t i = 0; i < n; ++i) {
|
||||||
|
printf("%d ", A[res[i]]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int weight = n - bit_weight(choices);
|
||||||
|
for (unsigned int i = 0; i < 64; ++i) {
|
||||||
|
uint64_t next = 1L << i;
|
||||||
|
if (choices & next) {
|
||||||
|
res[weight] = i;
|
||||||
|
permutations_aux(n, A, res, choices & ~next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void permutations(const size_t n, int A[static n]) {
|
||||||
|
int *res = malloc(sizeof(int) * n);
|
||||||
|
permutations_aux(n, A, res, (1L << n) - 1);
|
||||||
|
free(res);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The above approach prints out all permutations of a given array, provided the array contains at most `64` digits. It relies on `bit_weight` as defined in [[binary/index|binary]].
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What *is* a permutation?
|
||||||
|
Back: An ordered arrangement of some collection of objects.
|
||||||
|
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: 1708366788567-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How many permutations are there of $n$ objects?
|
||||||
|
Back: $n!$
|
||||||
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
|
<!--ID: 1708366788573-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is permutation expressed recursively?
|
||||||
|
Back: Put each candidate in the current position, finding all permutations of the remainder each time.
|
||||||
|
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: 1708369553046-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is $n!$ permutations of $n$ objects derived?
|
||||||
|
Back: There are $n$ choices for the first position, $n - 1$ choices for the second, etc.
|
||||||
|
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: 1708366788576-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What combinatorial concept explains $n!$ permutations of $n$ objects?
|
||||||
|
Back: The multiplicative principle.
|
||||||
|
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: 1708366788580-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What combinatorial concept is often associated with the factorial?
|
||||||
|
Back: Permutations.
|
||||||
|
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: 1708366788583-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How does sorting relate to the concept of permutations?
|
||||||
|
Back: Sorting aims to efficiently find a specific permutation.
|
||||||
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
|
Tags: algorithm
|
||||||
|
<!--ID: 1708366788587-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What symbol denotes "$n$ factorial"?
|
||||||
|
Back: $n!$
|
||||||
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
|
<!--ID: 1708366788590-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is $n!$ shorthand for?
|
||||||
|
Back: $\Pi_{k=1}^n k$
|
||||||
|
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: 1708366788594-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the identity element of $\cdot$ (multiplication)?
|
||||||
|
Back: $1$
|
||||||
|
Reference: Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
|
||||||
|
<!--ID: 1708366788597-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does $0!$ (factorial) evaluate to?
|
||||||
|
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: 1708366788600-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
*Why* might $0! = 1$ (barring convention)?
|
||||||
|
Back: Because the empty product is $1$, the multiplication identity.
|
||||||
|
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: 1708366788603-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What combinatorial concept explains the number of bijective functions between two finite sets?
|
||||||
|
Back: Permutations (factorials).
|
||||||
|
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: 1708366788606-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How many bijective functions exist between $\{1, 2, 3\}$ and $\{a, b, c\}$?
|
||||||
|
Back: $3!$
|
||||||
|
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: 1708366788610-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How many bijective functions exist between finite sets $A$ and $B$ where $|A| = |B| = n$?
|
||||||
|
Back: $n!$
|
||||||
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
|
<!--ID: 1708366788613-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
If we generalize to choosing $k \leq n$ elements of $k$ objects, we can calculate the $k$-permutation of $n$. This is denoted as $(n)_k$, sometimes called the **falling factorial**. $$(n)_k = \frac{n!}{(n - k)!}$$
|
||||||
|
|
||||||
|
The derivation works by noting that we have $n - 0$ possible ways to pick the first object, $n - 1$ ways to pick the second, up until $n - (k - 1)$ ways to pick the last object.
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What *is* a $k$-permutation?
|
||||||
|
Back: An ordered arrangement, containing $k$ elements, of some collection of objects.
|
||||||
|
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: 1708366788616-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What is the closed formula for $(n)_k$ (falling factorial)?
|
||||||
|
Back: $$(n)_k = \frac{n!}{(n - k)!}$$
|
||||||
|
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: 1708366788619-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How many $k$-permutations are there of $n$ objects?
|
||||||
|
Back: $(n)_k$
|
||||||
|
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: 1708366788622-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How is $(n)_k$ $k$-permutations of $n$ objects derived?
|
||||||
|
Back: There are $n$ choices for the first position, $n - 1$ choices for the second, etc. up until $n - (k - 1)$ choices for the last position.
|
||||||
|
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: 1708366788625-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does $(n)_n$ evaluate to?
|
||||||
|
Back: $n!$
|
||||||
|
Reference: Oscar Levin, *Discrete Mathematics: An Open Introduction*, 3rd ed., n.d., [https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf](https://discrete.openmathbooks.org/pdfs/dmoi3-tablet.pdf).
|
||||||
|
<!--ID: 1708366788628-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What does $(n)_0$ evaluate to?
|
||||||
|
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: 1708366788631-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Cloze
|
||||||
|
In a $k$-permutation of $n$ objects, there are $n - 0$ choices for first object and {$n - (k - 1)$} choices for the last object.
|
||||||
|
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: 1708366788634-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
What combinatorial concept explains the number of injective functions between two finite sets?
|
||||||
|
Back: $k$-permutations (falling factorials).
|
||||||
|
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: 1708366788638-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
%%ANKI
|
||||||
|
Basic
|
||||||
|
How many injective functions exist between $\{1, 2, 3\}$ and $\{a, b, c, d, e\}$?
|
||||||
|
Back: $(5)_3$
|
||||||
|
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: 1708366788641-->
|
||||||
|
END%%
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
* Gries, David. *The Science of Programming*. Texts and Monographs in Computer Science. New York: Springer-Verlag, 1981.
|
||||||
|
* 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).
|
Loading…
Reference in New Issue