From e010fb27e8571bb36fdc90ef454c5ce7534273d1 Mon Sep 17 00:00:00 2001 From: Antti H S Laaksonen Date: Mon, 17 Apr 2017 11:23:40 +0300 Subject: [PATCH] Better definition for function f [closes #31] --- chapter18.tex | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/chapter18.tex b/chapter18.tex index 81c7ab3..ca06440 100644 --- a/chapter18.tex +++ b/chapter18.tex @@ -21,8 +21,10 @@ For example, such queries are: The $k$th \key{ancestor} of a node $x$ in a rooted tree is the node that we will reach if we move $k$ levels up from $x$. -Let $f(x,k)$ denote the $k$th ancestor of $x$. -For example, in the following tree, $f(2,1)=1$ and $f(8,2)=4$. +Let $f(x,k)$ denote the $k$th ancestor of a node $x$ +(or $0$ if there is no such an ancestor). +For example, in the following tree, $f(2,1)=1$, $f(8,2)=4$ +and $f(5,2)=0$. \begin{center} \begin{tikzpicture}[scale=0.9] @@ -74,9 +76,6 @@ $\cdots$ \\ \end{tabular} \end{center} -The value $0$ means that the $k$th ancestor -of a node does not exist. - The preprocessing takes $O(n \log n)$ time, because each node can have at most $n$ ancestors. After this, any value of $f(x,k)$ can be calculated