Subtree Mode and Applications

๐Ÿ“… 2025-11-03
๐Ÿ“ˆ Citations: 0
โœจ Influential: 0
๐Ÿ“„ PDF
๐Ÿค– AI Summary
This paper addresses the subtree pattern query problem on leaf-colored trees: given any node, efficiently identify the most frequent color in its subtree. We formally define this problem and propose the first time-optimal linear-time algorithm (O(N)), leveraging depth-first traversal combined with offline frequency aggregation to eliminate redundant counting. The algorithm naturally generalizes to node-colored trees and supports multimodal queries. Experimental evaluation on real-world datasets containing up to 7.3 billion nodes demonstrates that our method achieves at least a 10ร— speedup in query latency over state-of-the-art approaches, while significantly reducing memory overhead. These contributions provide an efficient new tool for subtree pattern mining in applications such as text analysis and hierarchical modeling of biological sequences.

Technology Category

Application Category

๐Ÿ“ Abstract
The mode of a collection of values (i.e., the most frequent value in the collection) is a key summary statistic. Finding the mode in a given range of an array of values is thus of great importance, and constructing a data structure to solve this problem is in fact the well-known Range Mode problem. In this work, we introduce the Subtree Mode (SM) problem, the analogous problem in a leaf-colored tree, where the task is to compute the most frequent color in the leaves of the subtree of a given node. SM is motivated by several applications in domains such as text analytics and biology, where the data are hierarchical and can thus be represented as a (leaf-colored) tree. Our central contribution is a time-optimal algorithm for SM that computes the answer for every node of an input $N$-node tree in $O(N)$ time. We further show how our solution can be adapted for node-colored trees, or for computing the $k$ most frequent colors, in the optimal $O(N)$ time, for any given $k=O(1)$. Moreover, we prove that a similarly fast solution for when the input is a sink-colored directed acyclic graph instead of a leaf-colored tree is highly unlikely. Our experiments on real datasets with trees of up to 7.3 billion nodes demonstrate that our algorithm is faster than baselines by at least one order of magnitude and much more space efficient. Last, we present case studies showing the effectiveness of our approach in pattern mining and sequence-to-database search applications.
Problem

Research questions and friction points this paper is trying to address.

Computing most frequent color in tree subtrees efficiently
Developing optimal linear-time algorithm for subtree mode queries
Extending solution to node-colored trees and top-k frequencies
Innovation

Methods, ideas, or system contributions that make the work stand out.

Linear-time algorithm for subtree mode queries
Extension to node-colored trees and top-k queries
Efficient processing of billion-node tree structures
๐Ÿ”Ž Similar Papers
No similar papers found.
J
Jialong Zhou
Kingโ€™s College London, London, UK
B
Ben Bals
CWI, Amsterdam, The Netherlands
M
Matei Tinca
Vrije Universiteit, Amsterdam, The Netherlands
A
Ai Guan
Kingโ€™s College London, London, UK
Panagiotis Charalampopoulos
Panagiotis Charalampopoulos
King's College London
Algorithms and data structuresCombinatorial pattern matchingAlgorithms for planar graphs
G
Grigorios Loukides
Kingโ€™s College London, London, UK
Solon P. Pissis
Solon P. Pissis
Senior Researcher, CWI
AlgorithmsData StructuresBig DataData MiningString Algorithms