[Paper Review] Efficiently computing runs on a trie
This paper introduces the concept of runs on tries—maximal periodic substrings along root-to-node paths—and presents an O(n log log n)-time, O(n)-space algorithm to compute all such runs in a trie with n edges. It establishes that the maximum number of runs is bounded above by n and provides a tight asymptotic lower bound of 0.993238n, demonstrating near-linear density of runs in tries.
A maximal repetition, or run, in a string, is a maximal periodic substring whose smallest period is at most half the length of the substring. In this paper, we consider runs that correspond to a path on a trie, or in other words, on a rooted edge-labeled tree where the endpoints of the path must be a descendant/ancestor of the other. For a trie with $n$ edges, we show that the number of runs is less than $n$. We also show an asymptotic lower bound on the maximum density of runs in tries: $\\lim_{n\ ightarrow\\infty}\ ho_\\mathcal{T}(n)/n \\geq 0.993238$ where $\ ho_{\\mathcal{T}}(n)$ is the maximum number of runs in a trie with $n$ edges. Furthermore, we also show an $O(n\\log \\log n)$ time and $O(n)$ space algorithm for finding all runs.
Motivation & Objective
- To extend the concept of string runs to rooted, edge-labeled trees (tries), where runs are maximal periodic substrings along root-to-node paths.
- To analyze the maximum number of runs possible in a trie with n edges, establishing upper and lower bounds.
- To design an efficient algorithm for computing all runs in a trie, improving upon prior O(n(log log n)^2) solutions.
- To explore connections between runs, Lyndon words, and longest common extension (LCE) queries in the trie context.
Proposed method
- Leverages the property that every run contains a Lyndon word (L-root) as a substring, using this to guide run detection in the trie.
- Applies a hierarchical decomposition of the trie using marked nodes at intervals of b^{4/5} to enable efficient LCE queries on substrings of length b^{4/5}.
- Uses a suffix tree to rename and sort canonical paths (of length x^2 = b^{4/5}) to enable linear-time sorting and LCE computation via range minimum queries.
- Employs a two-level LCE strategy: first compute LCE on renamed path segments (length b^{4/5}), then resolve remaining short prefixes using constant-time LCE on the original paths.
- Uses radix sort and range minimum query structures to compute LCE between lexicographically adjacent renamed canonical paths in O(n) time.
- Combines these techniques to answer a batch of O(n) tree-path LCE queries in O(n log log n) total time, forming the core of the run-finding algorithm.
Experimental results
Research questions
- RQ1What is the maximum number of runs that can exist in a trie with n edges, and how does it compare to the number of edges?
- RQ2Can the concept of runs in strings be meaningfully generalized to rooted, edge-labeled trees (tries), and what structural properties do such runs possess?
- RQ3Is there an efficient algorithm to compute all runs in a trie, and what is the best possible time complexity achievable?
- RQ4What is the asymptotic density of runs in tries, and how close can it get to n as n grows?
- RQ5Can techniques from string run computation—such as Lyndon word properties and LCE data structures—be adapted to the trie setting?
Key findings
- The maximum number of runs in a trie with n edges is strictly less than n, establishing an upper bound of ρ(n) ≤ n.
- The asymptotic lower bound on run density is at least 0.993238, i.e., lim_{n→∞} ρ_T(n)/n ≥ 0.993238.
- An O(n log log n)-time, O(n)-space algorithm is presented for computing all runs in a trie with an integer alphabet.
- The algorithm relies on hierarchical path decomposition, renaming of canonical paths, and efficient LCE computation using range minimum queries.
- The method enables output of all primitively rooted squares in O(n log n) time, which is tight due to the existence of Θ(n log n) such squares in certain tries.
- The results demonstrate that runs in tries are not only numerous but also efficiently computable, with only a modest increase in time complexity compared to string runs.
Better researchstarts right now
From reading papers to final review, dramatically reduce your research time.
No credit card · Free plan available
This review was created by AI and reviewed by human editors.