We examine the amount of preprocessing needed for answering certain on-line queries as fast as possible. We start with the following basic problem. Suppose we are given a semigroup $(S,\circ )$. Let $s_1 ,\ldots, s_n$ be elements of $S$. We want to answer on-line queries of the form, ``What is the product $s_i \circ s_{i+1} \circ \cdots \circ s_{j-1} \circ s_j$?'' for any given $1\le i\le j\le n$. We show that a preprocessing of $\Theta(n \lambda (k,n))$ time and space is both necessary and sufficient to answer each such query in at most $k$ steps, for any fixed $k$. The function $\lambda (k,\cdot)$ is the inverse of a certain function at the $\lfloor {k/2}\rfloor$-th level of the primitive recursive hierarchy. In case linear preprocessing is desired, we show that one can answer each such query in $O( \alpha (n))$ steps and that this is best possible. The function $\alpha (n)$ is the inverse Ackermann function. We also consider the following extended problem. Let $T$ be a tree with an element of $S$ associated with each of its vertices. We want to answer on-line queries of the form, ``What is the product of the elements associated with the vertices along the path from $u$ to $v$?'' for any pair of vertices $u$ and $v$ in $T$. We derive results that are similar to the above, for the preprocessing needed for answering such queries. All our sequential preprocessing algorithms can be parallelized efficiently to give optimal parallel algorithms which run in $O(\log n)$ time on a CREW PRAM. These parallel algorithms are optimal in both running time and total number of operations. Our algorithms, especially for the semigroup of the real numbers with the minimum or maximum operations, have various applications in certain graph algorithms, in the utilization of communication networks and in Database retrieval.
翻译:我们研究了为尽可能快速回答某些在线查询所需的预处理量。我们从以下基本问题开始。假设给定一个半群 $(S,\circ )$。令 $s_1 ,\ldots, s_n$ 为 $S$ 中的元素。我们希望在线回答形式为“对于任意给定的 $1\le i\le j\le n$,乘积 $s_i \circ s_{i+1} \circ \cdots \circ s_{j-1} \circ s_j$ 是多少?”的查询。我们证明,对于任意固定的 $k$,需要 $\Theta(n \lambda (k,n))$ 时间和空间的预处理既是必要的也是充分的,以便在最多 $k$ 步内回答每个此类查询。函数 $\lambda (k,\cdot)$ 是原始递归层次结构第 $\lfloor {k/2}\rfloor$ 层中某个函数的逆。若希望进行线性预处理,我们证明可以在 $O( \alpha (n))$ 步内回答每个此类查询,并且这是最优的。函数 $\alpha (n)$ 是逆阿克曼函数。我们还考虑了以下扩展问题。令 $T$ 为一棵树,其每个顶点关联一个 $S$ 中的元素。我们希望在线回答形式为“对于 $T$ 中任意顶点对 $u$ 和 $v$,沿从 $u$ 到 $v$ 路径上顶点关联元素的乘积是多少?”的查询。我们针对回答此类查询所需的预处理,得出了与上述相似的结果。我们所有的顺序预处理算法都可以高效并行化,从而产生在 CREW PRAM 上以 $O(\log n)$ 时间运行的最优并行算法。这些并行算法在运行时间和总操作数上都是最优的。我们的算法,特别是针对具有最小值或最大值操作的实数半群,在图算法、通信网络利用和数据库检索中具有多种应用。