Better definition for function f [closes #31]
This commit is contained in:
parent
c1ac1df7dc
commit
e010fb27e8
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue