English

Longest Common Extensions in Trees

Data Structures and Algorithms 2015-07-10 v3

Abstract

The longest common extension (LCE) of two indices in a string is the length of the longest identical substrings starting at these two indices. The LCE problem asks to preprocess a string into a compact data structure that supports fast LCE queries. In this paper we generalize the LCE problem to trees and suggest a few applications of LCE in trees to tries and XML databases. Given a labeled and rooted tree TT of size nn, the goal is to preprocess TT into a compact data structure that support the following LCE queries between subpaths and subtrees in TT. Let v1v_1, v2v_2, w1w_1, and w2w_2 be nodes of TT such that w1w_1 and w2w_2 are descendants of v1v_1 and v2v_2 respectively. \begin{itemize} \item \LCEPP(v1,w1,v2,w2)\LCEPP(v_1, w_1, v_2, w_2): (path-path \LCE\LCE) return the longest common prefix of the paths v1w1v_1 \leadsto w_1 and v2w2v_2 \leadsto w_2. \item \LCEPT(v1,w1,v2)\LCEPT(v_1, w_1, v_2): (path-tree \LCE\LCE) return maximal path-path LCE of the path v1w1v_1 \leadsto w_1 and any path from v2v_2 to a descendant leaf. \item \LCETT(v1,v2)\LCETT(v_1, v_2): (tree-tree \LCE\LCE) return a maximal path-path LCE of any pair of paths from v1v_1 and v2v_2 to descendant leaves. \end{itemize} We present the first non-trivial bounds for supporting these queries. For \LCEPP\LCEPP queries, we present a linear-space solution with O(logn)O(\log^{*} n) query time. For \LCEPT\LCEPT queries, we present a linear-space solution with O((loglogn)2)O((\log\log n)^{2}) query time, and complement this with a lower bound showing that any path-tree LCE structure of size O(n\polylog(n))O(n \polylog(n)) must necessarily use Ω(loglogn)\Omega(\log\log n) time to answer queries. For \LCETT\LCETT queries, we present a time-space trade-off, that given any parameter τ\tau, 1τn1 \leq \tau \leq n, leads to an O(nτ)O(n\tau) space and O(n/τ)O(n/\tau) query-time solution. This is complemented with a reduction to the the set intersection problem implying that a fast linear space solution is not likely to exist.

Keywords

Cite

@article{arxiv.1412.1254,
  title  = {Longest Common Extensions in Trees},
  author = {Philip Bille and Pawel Gawrychowski and Inge Li Goertz and Gad M. Landau and Oren Weimann},
  journal= {arXiv preprint arXiv:1412.1254},
  year   = {2015}
}
R2 v1 2026-06-22T07:18:53.702Z