Saved in:
Bibliographic Details
Main Authors: Zhou, Jialong, Bals, Ben, Tinca, Matei, Guan, Ai, Charalampopoulos, Panagiotis, Loukides, Grigorios, Pissis, Solon P.
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2511.01376
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911391214993408
author Zhou, Jialong
Bals, Ben
Tinca, Matei
Guan, Ai
Charalampopoulos, Panagiotis
Loukides, Grigorios
Pissis, Solon P.
author_facet Zhou, Jialong
Bals, Ben
Tinca, Matei
Guan, Ai
Charalampopoulos, Panagiotis
Loukides, Grigorios
Pissis, Solon P.
contents 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, for any given $k=O(1)$, in the optimal $O(N)$ time. 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. They also show that it is effective in pattern mining, sequence-to-database search, and biology applications.
format Preprint
id arxiv_https___arxiv_org_abs_2511_01376
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Subtree Mode and Applications
Zhou, Jialong
Bals, Ben
Tinca, Matei
Guan, Ai
Charalampopoulos, Panagiotis
Loukides, Grigorios
Pissis, Solon P.
Data Structures and Algorithms
Databases
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, for any given $k=O(1)$, in the optimal $O(N)$ time. 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. They also show that it is effective in pattern mining, sequence-to-database search, and biology applications.
title Subtree Mode and Applications
topic Data Structures and Algorithms
Databases
url https://arxiv.org/abs/2511.01376