Skip to content

Commit 74dbf3b

Browse files
dufferzafarjakobkogler
authored andcommitted
Fixup headings etc. (#329)
1 parent 10ae04f commit 74dbf3b

File tree

10 files changed

+33
-30
lines changed

10 files changed

+33
-30
lines changed

src/algebra/fibonacci-numbers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ There can only be $p$ different remainders modulo $p$, and at most $p^2$ differe
134134
135135
We now choose two pairs of identical remainders with the smallest indices in the sequence. Let the pairs be $(F_a,\ F_{a + 1})$ and $(F_b,\ F_{b + 1})$. We will prove that $a = 1$. If this was false, there would be two previous pairs $(F_{a-1},\ F_a)$ and $(F_{b-1},\ F_b)$, which, by the property of Fibonacci numbers, would also be equal. However, this contradicts the fact that we had chosen pairs with the smallest indices, completing our proof.
136136
137-
##Practice Problems
137+
## Practice Problems
138138
139139
* [SPOJ - Euclid Algorithm Revisited](http://www.spoj.com/problems/MAIN74/)
140140
* [SPOJ - Fibonacci Sum](http://www.spoj.com/problems/FIBOSUM/)

src/combinatorics/catalan-numbers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void init() {
6161
}
6262
```
6363

64-
###Analytical formula
64+
### Analytical formula
6565
$$C_n = \frac{1}{n + 1} {\binom{2n}{n}}$$
6666

6767
(here $\binom{n}{k}$ denotes the usual binomial coefficient, i.e. number of ways to select $k$ objects from set of $n$ objects).

src/geometry/point-in-convex-polygon.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!--?title Check if point belongs to the convex polygon in O(log N) -->
2-
#Check if point belongs to the convex polygon in $O(\log N)$
2+
# Check if point belongs to the convex polygon in $O(\log N)$
33

44
Consider the following problem: you are given a convex polygon with integer vertices and a lot of queries.
55
Each query is a point, for which we should determine whether it lies inside or on the boundary of the polygon or not.
66
Suppose the polygon is ordered counter-clockwise. We will answer each query in $O(\log n)$ online.
77

8-
##Algorithm
8+
## Algorithm
99
Let's pick the point with the smallest x-coordinate. If there are several of them, we pick the one with the smallest y-coordinate. Let's denote it as $p_0$.
1010
Now all other points $p_1,\dots,p_n$ of the polygon are ordered by their polar angle from the chosen point (because the polygon is ordered counter-clockwise).
1111

@@ -35,7 +35,7 @@ This checks if the area of the triangle $p_0, p_i, p_{i+1}$ has to exact same si
3535
If $p$ is outside, then the sum of those three triangle will be bigger than the size of the triangle.
3636
If it is inside, then it will be equal.
3737

38-
##Implementation
38+
## Implementation
3939

4040
The function `prepair` will make sure that the lexicographical smallest point (smallest x value, and in ties smallest y value) will be $p_0$, and computes the vectors $p_i - p_0$.
4141
Afterwards the function `pointInConvexPolygon` computes the result of a query.
@@ -107,5 +107,5 @@ bool pointInConvexPolygon(pt point){
107107
}
108108
```
109109
110-
##Problems
110+
## Problems
111111
[SGU253 Theodore Roosevelt](https://codeforces.com/problemsets/acmsguru/problem/99999/253)

src/geometry/point-location.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,5 @@ vector<pair<int, int>> point_location(DCEL planar, vector<pt> queries)
286286
}
287287
```
288288
289-
##Problems
289+
## Problems
290290
[TIMUS1848 - Fly Hunt](http://acm.timus.ru/problem.aspx?space=1&num=1848&locale=en)

src/graph/Assignment-problem-min-flow.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<!--?title Assignment problem solution using min-cost-flo< -->
3-
#Solving assignment problem using min-cost-flow
3+
# Solving assignment problem using min-cost-flow
44

55
The **assignment problem** has two equivalent statements:
66

@@ -9,15 +9,15 @@ The **assignment problem** has two equivalent statements:
99

1010
Here we will consider the solution of the problem based on the algorithm for finding the [minimum cost flow (min-cost-flow)](./graph/min_cost_flow.html), solving the assignment problem in $\mathcal{O}(N^5)$.
1111

12-
##Description
12+
## Description
1313

1414
Let's build a bipartite network: there is a source $S$, a drain $T$, in the first part there are $N$ vertices (corresponding to rows of the matrix, or orders), in the second there are also $N$ vertices (corresponding to the columns of the matrix, or machines). Between each vertex $i$ of the first set and each vertex $j$ of the second set, we draw an edge with bandwidth 1 and cost $A_{ij}$. From the source $S$ we draw edges to all vertices $i$ of the first set with bandwidth 1 and cost 0. We draw an edge with bandwidth 1 and cost 0 from each vertex of the second set $j$ to the drain $T$.
1515

1616
We find in the resulting network the maximum flow of the minimum cost. Obviously, the value of the flow will be $N$. Further, for each vertex $i$ of the first segment there is exactly one vertex $j$ of the second segment, such that the flow $F_{ij}$ = 1. Finally, this is a one-to-one correspondence between the vertices of the first segment and the vertices of the second part, which is the solution to the problem (since the found flow has a minimal cost, then the sum of the costs of the selected edges will be the lowest possible, which is the optimality criterion).
1717

1818
The complexity of this solution of the assignment problem depends on the algorithm by which the search for the maximum flow of the minimum cost is performed. The complexity will be $\mathcal{O}(N^5)$ using [Dijkstra](./graph/dijkstra.html) or $\mathcal{O}(N^6)$ using [Bellman-Ford](./graph/bellman_ford.html).
1919

20-
##Implementation
20+
## Implementation
2121

2222
The implementation given here is long, it can probably be significantly reduced.
2323
It uses the [D´Esopo-Pape algorithm](./graph/desopo_pape.html) for finding shortest paths.

src/graph/strongly-connected-components.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,12 @@ Here, $g$ is graph, $gr$ is transposed graph. Function $dfs1$ implements depth f
103103
* Thomas Cormen, Charles Leiserson, Ronald Rivest, Clifford Stein. Introduction to Algorithms [2005].
104104
* M. Sharir. A strong-connectivity algorithm and its applications in data-flow analysis [1979].
105105
106-
##Practice Problems
107-
- [SPOJ - Submerging Islands](http://www.spoj.com/problems/SUBMERGE/)
108-
- [SPOJ - Good Travels](http://www.spoj.com/problems/GOODA/)
109-
- [SPOJ - Lego](http://www.spoj.com/problems/LEGO/)
110-
- [Codechef - Chef and Round Run](https://www.codechef.com/AUG16/problems/CHEFRRUN)
106+
## Practice Problems
107+
108+
* [SPOJ - Submerging Islands](http://www.spoj.com/problems/SUBMERGE/)
109+
* [SPOJ - Good Travels](http://www.spoj.com/problems/GOODA/)
110+
* [SPOJ - Lego](http://www.spoj.com/problems/LEGO/)
111+
* [Codechef - Chef and Round Run](https://www.codechef.com/AUG16/problems/CHEFRRUN)
111112
* [Dev Skills - A Song of Fire and Ice](https://devskill.com/CodingProblems/ViewProblem/79)
112113
* [UVA - 11838 - Come and Go](https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2938)
113114
* [UVA 247 - Calling Circles](https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=183)

src/linear_algebra/rank-matrix.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--?title Rank of a matrix-->
22

3-
#Finding the rank of a matrix
3+
# Finding the rank of a matrix
44

55
**The rank of a matrix** is the largest number of linearly independent rows/columns of the matrix. The rank is not only defined for square matrices.
66

@@ -9,16 +9,16 @@ The rank of a matrix can also be defined as the largest order of any non-zero mi
99
Let the matrix be rectangular and have size $N \times M$.
1010
Note that if the matrix is square and its determinant is non-zero, then the rank is $N$ ($=M$); otherwise it will be less. Generally, the rank of a matrix does not exceed $\min (N, M)$.
1111

12-
##Algorithm
12+
## Algorithm
1313

1414
You can search for the rank using [Gaussian elimination](./linear_algebra/linear-system-gauss.html). We will perform the same operations as when solving the system or finding its determinant. But if at any step in the $i$-th column there are no rows with an non-empty entry among those that we didn't selected already, then we skip this step and decrease the rank by one (initially the rank is set equal to $\max (N, M)$).
1515
Otherwise, if we have found a row with a non-zero element in the $i$-th column during the $i$-th step, then we mark this row as a selected one and perform the usual operations of taking this row away from the rest.
1616

17-
##Complexity
17+
## Complexity
1818

1919
This algorithm runs in $\mathcal{O}(n^3)$.
2020

21-
##Implementation
21+
## Implementation
2222

2323
```cpp
2424
const double EPS = 1E-9;

src/num_methods/simpson-integration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<!--?title Simpson integration -->
22

3-
#Integration by Simpson's formula
3+
# Integration by Simpson's formula
44

55
We are going to calculate the value of a definite integral
66

77
$$\int_a ^ b f (x) dx$$
88

99
The solution described here was published in one of the dissertations of **Thomas Simpson** in 1743.
1010

11-
##Simpson's formula
11+
## Simpson's formula
1212

1313
Let $n$ be some natural number. We divide the integration segment $[a; b]$ into $2n$ equal parts:
1414

@@ -29,7 +29,7 @@ Adding these values over all segments, we obtain the final **Simpson's formula**
2929

3030
$$\int_a ^ b f (x) dx \approx \left(f (x_0) + 4 f (x_1) + 2 f (x_2) + 4f(x_3) + 2 f(x_4) + \ldots + 4 f(x_{2N-1}) + f(x_{2N}) \right)\frac {h} {3} $$
3131

32-
##Error
32+
## Error
3333
The error in approximating an integral by Simpson's formula is
3434

3535
$$ -\tfrac{1}{90} \left(\tfrac{b-a}{2}\right)^5 f^{(4)}(\xi)$$
@@ -38,7 +38,7 @@ where $\xi$ is some number between $a$ and $b$.
3838

3939
The error is asymptotically proportional to $(b-a)^5$. However, the above derivations suggest an error proportional to $(b-a)^4$. Simpson's rule gains an extra order because the points at which the integrand is evaluated are distributed symmetrically in the interval $[a, b]$.
4040

41-
##Implementation
41+
## Implementation
4242

4343
Here $f(x)$ is some user function.
4444

src/sequences/k-th.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!--?title K-th order statistic in O(N)-->
22

3-
#K-th order statistic in O(N)
3+
# K-th order statistic in O(N)
44

55
Given an array __A__ of size __N__ and a number __K__. The challenge is to find __K__-th largest number in the array, i.e., __K__-th order statistic.
66

77
The basic idea - to use the idea of quick sort algorithm. Actually, the algorithm is simple, it is more difficult to prove that it runs in an average of O(N), in contrast to the quick sort.
88

9-
#Implementation (not recursive):
9+
# Implementation (not recursive):
1010

1111
```cpp
1212
template <class T>
@@ -63,5 +63,7 @@ T order_statistics (std::vector<T> a, unsigned n, unsigned k)
6363
```
6464
6565
To note, in the standard C ++ library, this algorithm has already been implemented - it is called nth_element.
66+
6667
## Practice Problems
67-
- [CODECHEF: Median](https://www.codechef.com/problems/CD1IT1)
68+
69+
- [CODECHEF: Median](https://www.codechef.com/problems/CD1IT1)

src/string/suffix-array.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--?title Suffix Array-->
2-
#Suffix Array
2+
# Suffix Array
33

44
## Definition
55

@@ -30,15 +30,15 @@ Therefore the suffix array for $s$ will be $(2,~ 3,~ 0,~ 4,~ 1)$.
3030

3131
As a data structure it is widely used in areas such as data compression, bioinformatics and, in general, in any area that deals with strings and string matching problems.
3232

33-
##Construction
33+
## Construction
3434

35-
###$O(n^2 \log n)$ approach
35+
### $O(n^2 \log n)$ approach
3636

3737
This is the most naive approach.
3838
Get all the suffixes and sort them using quicksort or mergesort and simultaneously retain their original indices.
3939
Sorting uses $O(n \log n)$ comparisons, and since comparing two strings will additionally take $O(n)$ time, we get the final complexity of $O(n^2 \log n)$.
4040

41-
###$O(n \log n)$ approach
41+
### $O(n \log n)$ approach
4242

4343
Strictly speaking the following algorithm will not sort the suffixes, but rather the cyclic shifts of a string.
4444
However we can very easily derive an algorithm for sorting suffixes from it:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy