From d9aba33a6b52006222088784ef2683a4c952afe8 Mon Sep 17 00:00:00 2001 From: Le Bao Hiep Date: Wed, 26 Jul 2023 15:23:19 +0700 Subject: [PATCH] Fix typos --- src/algebra/bit-manipulation.md | 2 +- src/algebra/discrete-log.md | 4 ++-- src/algebra/garners-algorithm.md | 2 +- src/algebra/polynomial.md | 8 ++++---- src/graph/bridge-searching-online.md | 4 ++-- src/graph/lca_farachcoltonbender.md | 2 +- src/graph/min_cost_flow.md | 2 +- src/string/rabin-karp.md | 10 +++++----- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/algebra/bit-manipulation.md b/src/algebra/bit-manipulation.md index 36c30d909..76d117668 100644 --- a/src/algebra/bit-manipulation.md +++ b/src/algebra/bit-manipulation.md @@ -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$. diff --git a/src/algebra/discrete-log.md b/src/algebra/discrete-log.md index 1c16dccb0..dd899fb25 100644 --- a/src/algebra/discrete-log.md +++ b/src/algebra/discrete-log.md @@ -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: @@ -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 \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: diff --git a/src/algebra/garners-algorithm.md b/src/algebra/garners-algorithm.md index 1a34f8ba6..fada69fd1 100644 --- a/src/algebra/garners-algorithm.md +++ b/src/algebra/garners-algorithm.md @@ -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. diff --git a/src/algebra/polynomial.md b/src/algebra/polynomial.md index fe81cfa8e..0aadba26c 100644 --- a/src/algebra/polynomial.md +++ b/src/algebra/polynomial.md @@ -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. @@ -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). @@ -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: $$ diff --git a/src/graph/bridge-searching-online.md b/src/graph/bridge-searching-online.md index 0c5da3a4c..da3af4402 100644 --- a/src/graph/bridge-searching-online.md +++ b/src/graph/bridge-searching-online.md @@ -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. diff --git a/src/graph/lca_farachcoltonbender.md b/src/graph/lca_farachcoltonbender.md index 9c9b9e6ac..f67365511 100644 --- a/src/graph/lca_farachcoltonbender.md +++ b/src/graph/lca_farachcoltonbender.md @@ -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); diff --git a/src/graph/min_cost_flow.md b/src/graph/min_cost_flow.md index cdc2a6a22..9f96e575b 100644 --- a/src/graph/min_cost_flow.md +++ b/src/graph/min_cost_flow.md @@ -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 diff --git a/src/string/rabin-karp.md b/src/string/rabin-karp.md index 38625b285..e9dcc74da 100644 --- a/src/string/rabin-karp.md +++ b/src/string/rabin-karp.md @@ -37,13 +37,13 @@ vector 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 occurences; - for (int i = 0; i + S - 1 < T; i++) { - long long cur_h = (h[i+S] + m - h[i]) % m; + vector 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; } ```