8000 Fix typos by hieplpvip · Pull Request #1128 · cp-algorithms/cp-algorithms · GitHub
[go: up one dir, main page]

Skip to content

Fix typos #1128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/algebra/bit-manipulation.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ int countSetBits(int n)
}
```

### Addtional tricks
### Additional tricks

- $n ~\&~ (n + 1)$ clears all trailing ones: $0011~0111_2 \rightarrow 0011~0000_2$.
- $n ~|~ (n + 1)$ sets the last cleared bit: $0011~0101_2 \rightarrow 0011~0111_2$.
Expand Down
4 changes: 2 additions & 2 deletions src/algebra/discrete-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ This problem can be solved using the meet-in-the-middle method as follows:

## Complexity

We can calculate $f_1(p)$ in $O(\log m)$ using the [binary exponentation algorithm](binary-exp.md). Similarly for $f_2(q)$.
We can calculate $f_1(p)$ in $O(\log m)$ using the [binary exponentiation algorithm](binary-exp.md). Similarly for $f_2(q)$.

In the first step of the algorithm, we need to calculate $f_1$ for every possible argument $p$ and then sort the values. Thus, this step has complexity:

Expand Down Expand Up @@ -107,7 +107,7 @@ Internally, `map` uses a red-black tree to store values.
Thus this code is a little bit slower than if we had used an array and binary searched, but is much easier to write.

Notice that our code assumes $0^0 = 1$, i.e. the code will compute $0$ as solution for the equation $0^x 8000 \equiv 1 \pmod m$ and also as solution for $0^x \equiv 0 \pmod 1$.
This is an often used convention in algebra, but it's also not univerally accepted in all areas.
This is an often used convention in algebra, but it's also not universally accepted in all areas.
Sometimes $0^0$ is simply undefined.
If you don't like our convention, then you need to handle the case $a=0$ separately:

Expand Down
2 changes: 1 addition & 1 deletion src/algebra/garners-algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A mixed radix representation is a positional numeral system, that's a generaliza
For instance the decimal numeral system is a positional numeral system with the radix (or base) 10.
Every a number is represented as a string of digits $d_1 d_2 d_3 \dots d_n$ between $0$ and $9$, and
E.g. the string $415$ represents the number $4 \cdot 10^2 + 1 \cdot 10^1 + 5 \cdot 10^0$.
In general the string of digits $d_1 d_2 d_3 \dots d_n$ represents the number $d_1 b^{n-1} + d_2 b^{n-2} + \cdots + d_n b^0$ in the positional numberal system with radix $b$.
In general the string of digits $d_1 d_2 d_3 \dots d_n$ represents the number $d_1 b^{n-1} + d_2 b^{n-2} + \cdots + d_n b^0$ in the positional numeral system with radix $b$.

In a mixed radix system, we don't have one radix any more. The base varies from position to position.

Expand Down
8 changes: 4 additions & 4 deletions src/algebra/polynomial.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ In this section, we focus more on the definitions and "intuitive" properties of
### Polynomial multiplication

!!! info "Definition"
**Univariate polynomial** is an expresion of form $A(x) = a_0 + a_1 x + \dots + a_n x^n$.
**Univariate polynomial** is an expression of form $A(x) = a_0 + a_1 x + \dots + a_n x^n$.

The values $a_0, \dots, a_n$ are polynomial coefficients, typically taken from some set of numbers or number-like structures. In this article, we assume that the coefficients are taken from some [field](https://en.wikipedia.org/wiki/Field_(mathematics)), meaning that operations of addition, subtraction, multiplication and division are well-defined for them (except for division by $0$) and they generally behave in a similar way to real numbers.

Expand All @@ -25,7 +25,7 @@ Typical example of such field is the field of remainders modulo prime number $p$
For simplicity we will drop the term _univariate_, as this is the only kind of polynomials we consider in this article. We will also write $A$ instead of $A(x)$ wherever possible, which will be understandable from the context. It is assumed that either $a_n \neq 0$ or $A(x)=0$.

!!! info "Definition"
The **product** of two polynomials is defined by expanding it as an arythmetic expression:
The **product** of two polynomials is defined by expanding it as an arithmetic expression:

$$
A(x) B(x) = \left(\sum\limits_{i=0}^n a_i x^i \right)\left(\sum\limits_{j=0}^m b_j x^j\right) = \sum\limits_{i,j} a_i b_j x^{i+j} = \sum\limits_{k=0}^{n+m} c_k x^k = C(x).
Expand Down Expand Up @@ -69,12 +69,12 @@ The coefficient near $x^k$ in the polynomial $A(x)$ is denoted shortly as $[x^k]
### Formal power series

!!! info "Definition"
A **formal power series** is an infite sum $A(x) = a_0 + a_1 x + a_2 x^2 + \dots$, considered regardless of its convergence properties.
A **formal power series** is an infinite sum $A(x) = a_0 + a_1 x + a_2 x^2 + \dots$, considered regardless of its convergence properties.

In other words, when we consider e.g. a sum $1+\frac{1}{2}+\frac{1}{4}+\frac{1}{8}+\dots=2$, we imply that it _converges_ to $2$ when the number of summands approach infinity. However, formal series are only considered in terms of sequences that make them.

!!! info "Definition"
The **product** of formal power series $A(x)$ and $B(x)$, is also defined by expanding it as an arythmetic expression:
The **product** of formal power series $A(x)$ and $B(x)$, is also defined by expanding it as an arithmetic expression:


$$
Expand Down
4 changes: 2 additions & 2 deletions src/graph/bridge-searching-online.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ This function is used many times in the rest of the code, since after the compre
The DSU for the connected components is stored in the vector `dsu_cc`, and there is also an additional vector `dsu_cc_size` to store the component sizes.
The function `find_cc(v)` returns the leader of the connectivity component (which is actually the root of the tree).

The re-rooting of a tree `make_root(v)` works as descibed above:
The re-rooting of a tree `make_root(v)` works as described above:
if traverses from the vertex $v$ via the ancestors to the root vertex, each time redirecting the ancestor `par` in the opposite direction.
The link to the representative of the connected component `dsu_cc` is also updated, so that it points to the new root vertex.
After re-rooting we have to assign the new root the correct size of the connected component.
Also we have to be careful that we call `find_2ecc()` to get the representatives of the 2-edge-connected component, rather than some other vertex that have already been compressed.

The cycle finding and compression function `merge_path(a, b)` is also implemented as descibed above.
The cycle finding and compression function `merge_path(a, b)` is also implemented as described above.
It searches for the LCA of $a$ and $b$ be rising these nodes in parallel, until we meet a vertex for the second time.
For efficiency purposes we choose a unique identifier for each LCA finding call, and mark the traversed vertices with it.
This works in $O(1)$, while other approaches like using $set$ perform worse.
Expand Down
2 changes: 1 addition & 1 deletion src/graph/lca_farachcoltonbender.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int min_by_h(int i, int j) {
}

void precompute_lca(int root) {
// get euler tour & indices of first occurences
// get euler tour & indices of first occurrences
first_visit.assign(n, -1);
height.assign(n, 0);
euler_tour.reserve(2 * n);
Expand Down
2 changes: 1 addition & 1 deletion src/graph/min_cost_flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Sometimes the task is given a little differently:
you want to find the maximum flow, and among all maximal flows we want to find the one with the least cost.
This is called the **minimum-cost maximum-flow problem**.

Both these problems can be solved effectively with the algorithm of sucessive shortest paths.
Both these problems can be solved effectively with the algorithm of successive shortest paths.

## Algorithm

Expand Down
10 changes: 5 additions & 5 deletions src/string/rabin-karp.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ vector<int> rabin_karp(string const& s, string const& t) {
for (int i = 0; i < S; i++)
h_s = (h_s + (s[i] - 'a' + 1) * p_pow[i]) % m;

vector<int> occurences;
for (int i = 0; i + S - 1 < T; i++) {
long long cur_h = (h[i+S] + m - h[i]) % m;
vector<int> occurrences;
for (int i = 0; i + S - 1 < T; i++) {
long long cur_h = (h[i+S] + m - h[i]) % m;
if (cur_h == h_s * p_pow[i] % m)
occurences.push_back(i);
occurrences.push_back(i);
}
return occurences;
return occurrences;
}
```

Expand Down
0