diff --git a/others/appendix/list/list-en.tex b/others/appendix/list/list-en.tex index 44413bf96..e7662d9c5 100644 --- a/others/appendix/list/list-en.tex +++ b/others/appendix/list/list-en.tex @@ -101,16 +101,14 @@ \subsection{Access} \section{Basic operations} \index{List!length} -From the definition, we can count the length recursively. the length of the empty list is 0, or it is 1 plus the length of the sub-list. +We may count the length of a list recursively: the length of the empty list is 0 or it is 1 plus the length of the sub-list. -\be -\begin{array}{rcl} -length\ [\ ] & = & 0 \\ -length\ (x \cons xs) & = & 1 + length\ xs -\end{array} -\ee +\begin{lalign} + length\ [\ ] & = 0 \\ + length\ (x \cons xs) & = 1 + length\ xs +\end{lalign} -We traverse the list to count the length, the performance is bound to $O(n)$, where $n$ is the number of elements. We use $|X|$ as the length of $X$ when the context is clear. To avoid repeatedly counting, we can persist the length in a variable, and update it when mutate (add or delete). Below is the iterative length counting: +As we traverse the list to count the length, the performance is bound to $O(n)$, where $n$ is the number of elements. Denote the length of the list $X$ by $|X|$ when the context is clear. To avoid repeatedly counting, we may persist the length in a variable and update it when mutate (add or delete). Below is the iterative length counting: \begin{algorithmic}[1] \Function{Length}{X} @@ -130,7 +128,7 @@ \subsection{index} \be getAt\ i\ (x \cons xs) = \begin{cases} i = 0: & x \\ - i \neq 0: & getAt\ (i - 1)\ xs \\ + i \neq 0: & getAt\ (i - 1)\ xs \end{cases} \ee diff --git a/others/preface/preface-zh-cn.tex b/others/preface/preface-zh-cn.tex index 4a59989a2..e8f6efeb8 100644 --- a/others/preface/preface-zh-cn.tex +++ b/others/preface/preface-zh-cn.tex @@ -91,7 +91,7 @@ \subsection*{改进} 对$n$个自然数$x_1, x_2, \dotsc , x_n$,如果存在小于$n$的可用数,必然存在某个$x_i$不在区间$[0, n)$\footnote{左开右闭区间$[a, b)$包括$a$但不包括$b$。}内。否则这些数一定是$0, 1, \dotsc, n - 1$的某个排列,这种情况下,最小的可用自然数是$n$。 \be -\textit{minfree}(x_1, x_2, ..., x_n) \leq n +\textit{minfree}(x_1, x_2, \dotsc, x_n) \leq n \label{eq:min-free} \ee