Skip to content

Commit eb99845

Browse files
authored
chore/cleanup (#10)
* chore(ln9): move all images to `image` folder and remove `book.pdf` * ci: bump up linter ci version to mute warning for () and [] miss match * feat(ln9): use interval package to remove lint error also re-format the ln9
1 parent c3bb392 commit eb99845

8 files changed

Lines changed: 18 additions & 13 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
key: ${{ runner.os }}-${{ hashFiles('**/*.tex') }}-${{ hashFiles('**/*.bib') }}
2929

3030
- name: LaTeX linter
31-
uses: colinaaa/chktex-action@v1.1.1
31+
uses: colinaaa/chktex-action@v1.1.2
3232
continue-on-error: true
3333

3434
- name: Compile LaTeX document

book.pdf

-1.37 MB
Binary file not shown.

book.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
\usepackage[ruled,linesnumbered,vlined]{algorithm2e}
77
\usepackage{hyperref}
88
\usepackage{listings}
9+
\usepackage{interval}
10+
11+
\intervalconfig{
12+
soft open fences,
13+
}
914

1015
\def\figureautorefname{图}
1116

src/Ln9-NearestPoints.tex

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ \section{平面最近点对问题定义}
1212
设计算法寻找欧式距离最近的点对$(A,B)$
1313
\begin{figure}[htb]
1414
\centering
15-
\includegraphics[scale=0.5]{Ln9.image/NearestPointsDef.png}
15+
\includegraphics[scale=0.5]{image/NearestPointsDef.png}
1616
\caption{问题定义图例}\label{fig1}
1717
\end{figure}
1818

@@ -40,7 +40,7 @@ \subsection{分治问题}
4040

4141
\begin{figure}[htb]
4242
\centering
43-
\includegraphics[scale=0.5]{Ln9.image/NearestPointsDivide.png}
43+
\includegraphics[scale=0.5]{image/NearestPointsDivide.png}
4444
\caption{分治过程图例}\label{fig2}
4545
\end{figure}
4646

@@ -59,15 +59,15 @@ \subsection{合并结果}
5959
这里,我们将所有横坐标与分治点$p_{\lfloor\frac{n}{2}\rfloor}$的横坐标
6060
$x_{\lfloor\frac{n}{2}\rfloor}$差值小于$\delta$的点组成集合$B$,即
6161
\begin{equation*}
62-
B = \{p_i\ \big|\
62+
B = \{p_i\ \big|\
6363
\left|x_i - x_{\lfloor\frac{n}{2}\rfloor}\right| \le \delta ,\
6464
1 \le i \le n\}
65-
\end{equation*}
65+
\end{equation*}
6666
因为只有$B$集合中的点之间的距离才有可能小于$\delta$
6767
$B$集合如下图\autoref{fig3}中阴影部分所示:
6868
\begin{figure}[htb]
6969
\centering
70-
\includegraphics[scale=0.5]{Ln9.image/NearestPointsMerge.png}
70+
\includegraphics[scale=0.5]{image/NearestPointsMerge.png}
7171
\caption{合并过程图例}\label{fig3}
7272
\end{figure}
7373

@@ -84,12 +84,12 @@ \subsection{合并结果}
8484
考虑到$C(p_i)$会因为归并操作而维持在$O(n)$数量级,其实不然,该集合的大小不会超过7。下面给出
8585
证明。
8686

87-
根据定义,$C(p_i)$中的点的纵坐标均处于$(y_i - \delta, y_i]$范围内,且其中的所有点
87+
根据定义,$C(p_i)$中的点的纵坐标均处于$\interval[open left]{y_i - \delta}{y_i}$范围内,且其中的所有点
8888
的横坐标均处于$\left( x_m - \delta, x_m + \delta \right)$范围内。
8989
这样便构成了一个$2\delta\times\delta$的矩形。如下图\autoref{fig4}所示
9090
\begin{figure}[htb]
9191
\centering
92-
\includegraphics[scale=0.5]{Ln9.image/NearestPointsCpi.png}
92+
\includegraphics[scale=0.5]{image/NearestPointsCpi.png}
9393
\caption{$C(p_i)$}\label{fig4}
9494
\end{figure}。
9595

@@ -114,9 +114,9 @@ \section{分治算法的时间复杂度分析}
114114

115115
\[
116116
T(n) = \begin{cases}
117-
O(1) & 2 \le n \le 3 \\
117+
O(1) & 2 \le n \le 3 \\
118118
2T(\frac{n}{2}) + O(n) & n > 3
119-
\end{cases}
119+
\end{cases}
120120
\]
121121

122122
推导如下:
@@ -126,7 +126,7 @@ \section{分治算法的时间复杂度分析}
126126
&= 2^2T(\frac{n}{2^2}) + 2O(n)\\
127127
&\vdots \\
128128
&= 2^k T(\frac{n}{2^k}) + kO(n)\ \ (n = 2 ^ k)\\
129-
&= O(n) + O(n\log n) \\
129+
&= O(n) + O(n\log n) \\
130130
&= O(n\log n)
131131
\end{align*}
132132

@@ -139,7 +139,7 @@ \section{伪代码}
139139
}
140140
\KwResult{the minimum distance $\delta$}
141141
\Begin{
142-
\If{$\left| P \right| <= 3$}{
142+
\If{$\left| P \right| <= 3$}{
143143
Return the minimum Euclidean-Distance between each pair of points.
144144
}
145145
$m \leftarrow \lfloor \frac{n}{2} \rfloor$\;
@@ -155,4 +155,4 @@ \section{伪代码}
155155
Return $\delta$
156156
}
157157
\caption{Nearest-Pair\label{NPP}}
158-
\end{algorithm}
158+
\end{algorithm}

0 commit comments

Comments
 (0)