diff --git a/kirj.tex b/kirj.tex index 15e3cdb..7cf1e9b 100644 --- a/kirj.tex +++ b/kirj.tex @@ -20,12 +20,6 @@ \emph{Programming Pearls}. Addison-Wesley, 1986. -\bibitem{ber93} - O. Berkman and U. Vishkin. - Recursive star-tree parallel data structure. - \emph{SIAM Journal on Computing}, - 22(2):221--242, 1993. - \bibitem{cod15} Codeforces: On ''Mo's algorithm'', \url{http://codeforces.com/blog/entry/20032} @@ -55,6 +49,11 @@ A new data structure for cumulative frequency tables. \emph{Software: Practice and Experience}, 24(3):327--336, 1994. +\bibitem{fis06} + J. Fischer and V. Heun. + Theoretical and practical improvements on the RMQ-problem, with applications to LCA and LCE. + In \emph{Annual Symposium on Combinatorial Pattern Matching}, 36--48, 2006. + \bibitem{fis11} J. Fischer and V. Heun. Space-efficient preprocessing schemes for range minimum queries on static arrays. @@ -102,6 +101,11 @@ A method for the construction of minimum-redundancy codes. \emph{Proceedings of the IRE}, 40(9):1098--1101, 1952. +\bibitem{kar87} + R. M. Karp and M. O. Rabin. + Efficient randomized pattern-matching algorithms. + \emph{IBM Journal of Research and Development}, 31(2):249--260, 1987. + \bibitem{kas61} P. W. Kasteleyn. The statistics of dimers on a lattice: I. The number of dimer arrangements on a quadratic lattice. @@ -117,6 +121,17 @@ On the shortest spanning subtree of a graph and the traveling salesman problem. \emph{Proceedings of the American Mathematical Society}, 7(1):48--50, 1956. +\bibitem{ben00} + M. A. Bender and M. Farach-Colton. + The LCA problem revisited. In + \emph{Latin American Symposium on Theoretical Informatics}, 88--94, 2000. + +\bibitem{mai84} + M. G. Main and R. J. Lorentz. + An $O(n \log n)$ algorithm for finding all repetitions in a string. + \emph{Journal of Algorithms}, 5(3):422--432, 1984. + + \bibitem{pac13} J. Pachocki and J. Radoszweski. Where to use and how not to use polynomial string hashing. @@ -137,59 +152,9 @@ Gaussian elimination is not optimal. \emph{Numerische Mathematik}, 13(4):354--356, 1969. -\bibitem{tar84} - R. E. Tarjan and U. Vishkin. - Finding biconnected components and computing tree functions - in logarithmic parallel time. - \emph{25th Annual Symposium on Foundations of Computer Science}, 12--20, 1984. - \bibitem{tem61} H. N. V. Temperley and M. E. Fisher. Dimer problem in statistical mechanics -- an exact result. \emph{Philosophical Magazine}, 6(68):1061--1063, 1961. \end{thebibliography} -% -% -% \chapter*{Literature} -% \markboth{\MakeUppercase{Literature}}{} -% \addcontentsline{toc}{chapter}{Literature} -% -% \subsubsection{Textbooks on algorithms} -% -% \begin{itemize} -% \item T. H. Cormen, C. E. Leiserson, -% R. L Rivest and C. Stein: -% \emph{Introduction to Algorithms}, -% MIT Press, 2009 (3rd edition) -% \item J. Kleinberg and É. Tardos: -% \emph{Algorithm Design}, -% Pearson, 2005 -% \item S. S. Skiena: -% \emph{The Algorithm Design Manual}, -% Springer, 2008 (2nd edition) -% \end{itemize} -% -% \subsubsection{Textbooks on competitive programming} -% -% \begin{itemize} -% \item K. Diks, T. Idziaszek, -% J. Łącki and J. Radoszewski: -% \emph{Looking for a Challenge?}, -% University of Warsaw, 2012 -% \item S. Halim and F. Halim: -% \emph{Competitive Programming}, -% 2013 (3rd edition) -% \item S. S. Skiena and M. A. Revilla: -% \emph{Programming Challenges: The Programming -% Contest Training Manual}, -% Springer, 2003 -% \end{itemize} -% -% \subsubsection{Other books} -% -% \begin{itemize} -% \item J. Bentley: -% \emph{Programming Pearls}, -% Addison-Wesley, 1999 (2nd edition) -% \end{itemize} \ No newline at end of file diff --git a/kkkk.tex b/kkkk.tex index 7a7bc6f..f0aaaca 100644 --- a/kkkk.tex +++ b/kkkk.tex @@ -1,6 +1,6 @@ \documentclass[twoside,12pt,a4paper,english]{book} -\includeonly{luku27,kirj} +\includeonly{luku18,kirj} \usepackage[english]{babel} \usepackage[utf8]{inputenc} diff --git a/luku02.tex b/luku02.tex index 46e69e8..875c181 100644 --- a/luku02.tex +++ b/luku02.tex @@ -353,10 +353,10 @@ time and even in $O(n)$ time. Given an array of $n$ integers $x_1,x_2,\ldots,x_n$, our task is to find the -\key{maximum subarray sum}, i.e., +\key{maximum subarray sum}\footnote{Bentley's +book \emph{Programming Pearls} \cite{ben86} made this problem popular.}, i.e., the largest possible sum of numbers -in a contiguous region in the array\footnote{Jon Bentley's -book \emph{Programming Pearls} \cite{ben86} made this problem popular.}. +in a contiguous region in the array. The problem is interesting when there may be negative numbers in the array. For example, in the array diff --git a/luku09.tex b/luku09.tex index ba3ffa6..6b3eacf 100644 --- a/luku09.tex +++ b/luku09.tex @@ -245,7 +245,7 @@ to the position of $X$. Next we will see how we can process range minimum queries in $O(1)$ time after an $O(n \log n)$ time preprocessing\footnote{There are also -sophisticated techniques \cite{fis11} where the preprocessing time +sophisticated techniques \cite{fis06} where the preprocessing time is only $O(n)$, but such algorithms are not needed in competitive programming.}. Note that minimum and maximum queries can always diff --git a/luku18.tex b/luku18.tex index 242c1a5..7e445fb 100644 --- a/luku18.tex +++ b/luku18.tex @@ -85,9 +85,9 @@ as a sum where each term is a power of two. \section{Subtrees and paths} -\index{node array} +\index{tree traversal array} -A \key{node array}\footnote{A similar idea is sometimes called the \key{Euler tour technique} \cite{tar84}.} contains the nodes of a rooted tree +A \key{tree traversal array} contains the nodes of a rooted tree in the order in which a depth-first search from the root node visits them. For example, in the tree @@ -155,7 +155,7 @@ a depth-first search proceeds as follows: \end{tikzpicture} \end{center} -Hence, the corresponding node array is as follows: +Hence, the corresponding tree traversal array is as follows: \begin{center} \begin{tikzpicture}[scale=0.7] \draw (0,0) grid (9,1); @@ -186,8 +186,8 @@ Hence, the corresponding node array is as follows: \subsubsection{Subtree queries} Each subtree of a tree corresponds to a subarray -in the node array, -where the first element is the root node. +in the tree traversal array such that +the first element in the subarray is the root node. For example, the following subarray contains the nodes in the subtree of node $4$: \begin{center} @@ -265,7 +265,7 @@ is $3+4+3+1=11$. \end{tikzpicture} \end{center} -The idea is to construct a node array that contains +The idea is to construct a tree traversal array that contains three values for each node: (1) the identifier of the node, (2) the size of the subtree, and (3) the value of the node. For example, the array for the above tree is as follows: @@ -381,7 +381,7 @@ and calculate the sum of values in $O(\log n)$ time. \subsubsection{Path queries} -Using a node array, we can also efficiently +Using a tree traversal array, we can also efficiently calculate sums of values on paths from the root node to any other node in the tree. @@ -484,7 +484,7 @@ For example, the following array corresponds to the above tree: When the value of a node increases by $x$, the sums of all nodes in its subtree increase by $x$. For example, if the value of node 4 increases by 1, -the node array changes as follows: +the array changes as follows: \begin{center} \begin{tikzpicture}[scale=0.7] @@ -650,7 +650,7 @@ performed in $O(\log n)$ time. \subsubsection{Method 2} Another way to solve the problem is based on -a node array. +a tree traversal array \cite{ben00}. Once again, the idea is to traverse the nodes using a depth-first search: @@ -689,12 +689,13 @@ using a depth-first search: \end{tikzpicture} \end{center} -However, in this problem, -we add each node to the node array \emph{always} + +However, we use a bit different technique where +we add each node to the tree traversal array \emph{always} when the depth-first search visits the node, and not only at the first visit. Hence, a node that has $k$ children appears $k+1$ times -in the node array, and there are a total of $2n-1$ +in the array, and there are a total of $2n-1$ nodes in the array. We store two values in the array: diff --git a/luku26.tex b/luku26.tex index ff532b7..a90a8e5 100644 --- a/luku26.tex +++ b/luku26.tex @@ -196,7 +196,9 @@ from node $s$ using character $c$. \key{String hashing} is a technique that allows us to efficiently check whether two -substrings in a string are equal. +substrings in a string are equal\footnote{The technique +was popularized by the Karp–Rabin pattern matching +algorithm \cite{kar87}.}. The idea is to compare the hash values of the substrings instead of their individual characters. @@ -428,7 +430,10 @@ gives for each position $k$ in the string the length of the longest substring that begins at position $k$ and is a prefix of the string. Such an array can be efficiently constructed -using the \key{Z-algorithm} \cite{gus97}. +using the \key{Z-algorithm}\footnote{The Z-algorithm +was presented in \cite{gus97} as the simplest known +method for linear-time pattern matching, and the original idea +was attributed to \cite{mai84}.}. For example, the Z-array for the string \texttt{ACBACDACBACBACDA} is as follows: