Skip to content

Commit

Permalink
Updated preface
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxinyu95 committed Feb 26, 2024
1 parent 3f87adc commit b24ce43
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 43 deletions.
8 changes: 4 additions & 4 deletions others/preface/preface-en.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ \chapter*{Preface to the second edition}
\phantomsection % so hyperref creates bookmarks
\addcontentsline{toc}{chapter}{Preface to the second edition}

Some people did not see their works published, like Fermat and Galois; Some people refused to publish any `imperfect' works despite they had already been great and important (at least from our view point), like Gauss; Some people lost their works in fires or wars, like Riemann. We owe Samuel Fermat, who collected his father's notes and mails, published a special edition of {\em Arithmetica, augmented with Fermat's comments}; We owe Liouville, who re-discovered and published Galois' papers in {\em Journal de Mathématiques Pures et Appliquées}; We owe Dedekind, who collected the burnt notebook from Mrs Riemann after her husband's early death. We appreciate those publishers who save, protect, and spread human knowledge no matter it's profitable or not (in terms of money). The development of technology and internet greatly change the way that people write, log, edit, and publish things. I was able to write and share about elementary functional algorithms and data structures online from 2009. It was accumulated to a draft book by 2015, and was published in 2017 in Chinese.
Some people did not see their works published, like Fermat and Galois; Some people refused to publish any \enquote{imperfect} works despite they had already been great and important (at least from our view point), like Gauss; Some people lost some of their works in fires or wars, like Riemann. We owe Samuel Fermat, who collected his father's notes and mails, published a special edition of {\em Arithmetica, augmented with Fermat's comments}; We owe Liouville, who re-discovered and published Galois' papers in {\em Journal de Mathématiques Pures et Appliquées}; We owe Dedekind, who collected the burnt notebook from Mrs Riemann after her husband's early death. We appreciate those publishers who save, protect, and spread human knowledge no matter it's profitable or not (in terms of money). The development of technology and internet greatly change the way that people write, log, edit, and publish things. I was able to write and share about elementary functional algorithms and data structures online from 2009. It was accumulated to a draft book by 2015, and was published in 2017 in Chinese.

I always think I am so lucky compare to the people in the past. It's impossible to make this happen before, while there are plenty of wonderful works in this domain yet to be published. Thanks to the editors, the publisher, and every reader. I collected the feedback, questions, and comments, started to re-write the book from the end of 2020, and completed a new edition by May 2023. The main changes are:

Expand All @@ -34,7 +34,7 @@ \chapter*{Preface to the second edition}

\item Reorganize the book structure. (a) Move the list to the first chapter, make it friendly to the new readers to the functional programming; (b) Add a section of paired-list B-tree in chapter 7. Add the remove algorithms to the red-black tree and AVL tree to the appendix; (c) Remove the chapter of the suffix tree. For imperative string matching, focus on KMP algorithm, and remove the Boyer-Moore algorithm; (d) Add the answers to all the 120 exercises.

\item Unify the programming language of the example programs. This is one of the most feedback to the first edition. Use Haskell for functional examples, and consolidate imperative ones in a language named `Bourbaki' (Nicolas Bourbaki is the pseudonym of a group of (mainly) French mathematicians, including André Weil, Henri Cartan, and etc. The virtual figure indicates the programming language does not exist, while it reflects some popular languages behind, like Python, Java, Kotlin and etc.). Collect the examples as an appendix after each chapter.
\item Unify the programming language of the example programs. This is one of the most feedback to the first edition. Use Haskell for functional examples, and consolidate imperative ones in a language named `Bourbaki' (Nicolas Bourbaki is the pseudonym of a group of (mainly) French mathematicians, including André Weil, Henri Cartan, and etc. The virtual figure indicates the programming language does not exist, while it reflects some popular languages behind, like Python, Java, C and etc.). Collect the examples as an appendix after each chapter.

\item Correct all known errors in the first edition.
\end{enumerate}
Expand Down Expand Up @@ -171,7 +171,7 @@ \subsection*{Divide and Conquer}
\end{cases}
\]

This algorithm needn't additional space\footnote{The recursion takes $O(\lg n)$ stack spaces, which can be eliminated through tail recursion optimization}. Each recursive call performs $O(|A|)$ comparisons to partition $A'$ and $A''$, hence halves the problem as $T(n) = T(n/2) + O(n)$. The time complexity reduces to $O(n)$ by the master theorem\footnote{Alternatively, the first call takes $O(n)$ time to partition $A'$ and $A''$, the second call takes $O(n/2)$ time, the third call takes $O(n/4)$ time ... The total time is $O(n + n/2 + n/4 + ...) = O(2n) = O(n)$.}. Below example program implements this algorithm.
This algorithm needn't additional space\footnote{The recursion takes $O(\lg n)$ stack spaces, which can be eliminated through tail recursion optimization}. Each recursive call performs $O(|A|)$ comparisons to partition $A'$ and $A''$, hence halves the problem as $T(n) = T(n/2) + O(n)$. The time complexity reduces to $O(n)$ by the master theorem\footnote{Alternatively, the first call takes $O(n)$ time to partition $A'$ and $A''$, the second call takes $O(n/2)$ time, the third call takes $O(n/4)$ time ... The total time is $O(n + n/2 + n/4 + \dotsc) = O(2n) = O(n)$.}. Below example program implements this algorithm.

\lstset{frame = single}
\begin{Haskell}
Expand Down Expand Up @@ -289,7 +289,7 @@ \subsection*{Improvement}
\EndFunction
\end{algorithmic}

The \textproc{Unique-Enqueue} function takes $O(m)$ time to insert a unique number in ascending order, where $m = |Q|$ is the length of the queue. It increases proportion to $n$ (Each time, we dequeue an element, and enqueue at most 3. The increasing ratio $\leq$ 2), the total time is $O(1 + 2 + 3 + ... + n) = O(n^2)$. \Cref{fig:big-O-1q} shows the queue access times against $n$. The quadratic curve reflects the $O(n^2)$ performance.
The \textproc{Unique-Enqueue} function takes $O(m)$ time to insert a unique number in ascending order, where $m = |Q|$ is the length of the queue. It increases proportion to $n$ (Each time, we dequeue an element, and enqueue at most 3. The increasing ratio $\leq$ 2), the total time is $O(1 + 2 + 3 + \dotsb + n) = O(n^2)$. \Cref{fig:big-O-1q} shows the queue access times against $n$. The quadratic curve reflects the $O(n^2)$ performance.

\begin{figure}[htbp]
\centering
Expand Down
Loading

0 comments on commit b24ce43

Please sign in to comment.