## 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 T of size n, the goal is to preprocess T into a compact data structure that support the following LCE queries between subpaths and subtrees in T. Let v_{1}, v_{2}, w_{1}, and w_{2} be nodes of T such that w_{1} and w_{2} are descendants of v_{1} and v_{2} respectively.•LCEPP(v_{1},w_{1},v_{2},w_{2}): (path-path LCE) return the longest common prefix of the paths v_{1}→w_{1} and v_{2}→w_{2}.•LCEPT(v_{1},w_{1},v_{2}): (path-tree LCE) return maximal path-path LCE of the path v_{1}→w_{1} and any path from v_{2} to a descendant leaf.•LCETT(v_{1},v_{2}): (tree-tree LCE) return a maximal path-path LCE of any pair of paths from v_{1} and v_{2} to descendant leaves. We present the first non-trivial bounds for supporting these queries. For LCE_{PP} queries, we present a linear-space solution with O(log^{*} n) query time. For LCE_{PT} queries, we present a linear-space solution with O((log log n)^{2}) query time, and complement this with a lower bound showing that any path-tree LCE structure of size O(npolylog(n)) must necessarily use Ω(log log n) time to answer queries. For LCE_{TT} queries, we present a time-space trade-off, that given any parameter τ, 1≤τ≤n, leads to an O(nτ) space and O(n/τ) query-time solution (all of these bounds hold on a standard unit-cost RAM model with logarithmic word size). This is complemented with a reduction from the set intersection problem implying that a fast linear space solution is not likely to exist.

Original language | English |
---|---|

Pages (from-to) | 98-107 |

Number of pages | 10 |

Journal | Theoretical Computer Science |

Volume | 638 |

DOIs | |

State | Published - 25 Jul 2016 |

### Bibliographical note

Publisher Copyright:© 2015 Elsevier B.V.

## Keywords

- Longest common prefix
- Pattern matching in trees
- Suffix tree of a tree

## ASJC Scopus subject areas

- Theoretical Computer Science
- General Computer Science