Conceptio › Archive › arXiv CS
arXiv CS open access

Nearly-Optimal Dynamic Subtree Mode

Jialong Zhou et al. · arxiv_cs
arXiv CS · Papers
Open Source ↗Direct PDF ↓
data-managementdatabasessqlstorage
Computing the mode (i.e., the most frequent element) in a range of an array, or in a path of a colored tree, has been studied extensively in both the static and dynamic setting. However, the problem of computing the mode in a subtree of a leaf-colored tree, referred to as the Subtree Mode (SM), has
Conceptio Open Archive

Analyze & explore related research in Conceptio

Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.

arXiv:2611.37616v1 [cs.DS] 27 Nov 2026

Nearly-Optimal Dynamic Subtree Mode Jialong Zhou∗

Ben Bals∗

King’s College London London, United Kingdom

CWI Amsterdam, The Netherlands Vrije Universiteit Amsterdam, The Netherlands

University of Tokyo Tokyo, Japan

Grigorios Loukides

Solon P. Pissis

Kunihiko Sadakane

King’s College London London, United Kingdom

The Cyprus Institute Nicosia, Cyprus

University of Tokyo Tokyo, Japan

Sankardeep Chakraborty

November 30, 2026

Abstract Computing the mode (i.e., the most frequent element) in a range of an array, or in a path of a colored tree, has been studied extensively in both the static and dynamic setting. However, the problem of computing the mode in a subtree of a leaf-colored tree, referred to as the Subtree Mode (SM), has only been studied in the static setting, despite its applications in domains ranging from file systems, to e-commerce, and bioinformatics. Here, we study the SM problem as the tree undergoes changes. We define Dynamic Subtree Mode (DSM), which asks for a data structure supporting leaf recolorings in a fixed tree, and Fully Dynamic Subtree Mode (FDSM), which additionally supports leaf insertions and deletions and subtree moves. For DSM on a tree of 𝑛 nodes, we propose a linear-space data structure with O (𝑛) preprocessing e(𝑛 𝛼 ) and O e(𝑛1− 𝛼 ), respectively. This trade-off is and, for any 𝛼 ∈ [0, 1], query and update times O polynomially optimal under the Online Matrix-Vector Multiplication conjecture. For trees of height ℎ, e(1) and O e(ℎ), respectively. For FDSM, a logarithmic-overhead query and update times improve to O reduction from Dynamic Range Mode gives a conditional lower bound. For a color set Δ, we obtain a e(|Δ|) time and recolorings and linear-space data structure supporting queries and subtree moves in O e leaf insertions and deletions in O (1) time. Thus, while DSM exploits the tree structure to achieve query–update trade-offs that are conditionally impossible for Dynamic Range Mode, FDSM inherits its conditional hardness but admits efficient solutions when |Δ| is small. Experiments on datasets from different domains, as well as case studies using workloads from e-commerce and file systems, show speedups of orders of magnitude over natural baselines.

∗ The first two authors contributed equally to this work. All other authors are sorted alphabetically.

Contents 1

Introduction 1.1 The Dynamic Subtree Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 The Fully Dynamic Subtree Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 1 2 4

2

Related Work

4

3

Preliminaries

5

DSM: An Optimal Smooth Trade-off

6 6 9

4

4.1 4.2

The Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Lower Bound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Low Tree Height Can Improve DSM

11

6 Why Is the Connectivity Not Dynamic?

12

5

7

Few Colors Allow FDSM

13

8

Experimental Evaluation 8.1 Datasets and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.3 DSM Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.4 FDSM Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.5 Case Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15 15 16 17 20 23

9

Conclusion

23

References

24

A Top-1 Document Retrieval with Document Additions

29

B Additional Material for Experimental Evaluation B.1 Details About the Datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B.2 Additional Results for DSM on News and Genes-sam . . . . . . . . . . . . . . . . . . . B.3 Additional Results for DSM for the Impact of 𝑛 . . . . . . . . . . . . . . . . . . . . . . B.4 Additional Results for the Impact of Color Count . . . . . . . . . . . . . . . . . . . . . B.5 Additional Results for FDSM on WebKB . . . . . . . . . . . . . . . . . . . . . . . . .

29 29 29 29 29 29

Update(𝑤, )

AddLeaf(𝑣, )

𝑝

Link-Cut(𝑢, 𝑣)

𝑝 𝑣

𝑢

𝑣 𝑢

Query( 𝑝) = (a)

𝑤

𝑧 (b)

(c)

(d)

Figure 1: A tree under successive operations.

1

Introduction

A key summary statistic of a collection of values is its mode (i.e., its most frequent value) [HKP11]. In most applications, however, users require finding the mode of specific parts of the data. For example, a market analyst queries e-commerce transaction logs to identify the most frequently purchased item over a specific promotional window [HL23], a network engineer queries a routing path to detect the prevailing traffic type [GH22], and a biologist queries a phylogenetic tree to determine the dominant mutation within a specific evolutionary clade [ZBT+ 26]. Due to the large number of queries and volume of data in such applications, constructing a data structure that supports fast querying of arbitrary parts of data is crucial. This leads to three fundamental problems, depending on how the data are modeled. When the data are modeled as an array, querying for the mode of a subarray (e.g., a contiguous window in sequential data, or a range of attribute values in a database) leads to the well-known Range Mode (RM) problem [KMS05, CDL+ 14, GJLT10, VX20]. When the data are modeled as a tree, querying for the mode of the labels along a tree path leads to the Path Mode (PM) problem [GH22], and querying for the mode of the labels of the leaves in the subtree of a node leads to the Subtree Mode (SM) problem [ZBT+ 26]. For example, consider the tree in Figure 1(a). The answer to a subtree mode query for node 𝑝 is , as this is the most frequent color among the leaves in its subtree. There are efficient data structures for all these three problems in the static setting (see Section 2). Yet, in most applications, the data are updated; purchased items are added into e-commerce transaction logs, network routing topologies adapt dynamically to link failures, and genome databases undergo new annotations. In this setting, it is impractical to build the (static) data structures for RM, PM, or SM from scratch after each update. Also, these data structures cannot be readily adapted to deal with updates. Thus, designing dynamic data structures that support both efficient queries and updates is necessary. The Dynamic Range Mode (DRM) problem, where an update modifies, inserts, or deletes an entry of an array of 𝑛 entries, has received significant attention [CDL+ 14, EZHMS18, SX20, GPVX21, JX22]. The state-of-the-art combinatorial data structure [EZHMS18] supports queries and updates in O (𝑛2/3 ) time using linear space. Using fast matrix multiplication, the query and update time can be improved to O (𝑛0.6524 ) using O (𝑛1.3262 ) space [GPVX21]. For the Dynamic Path Mode (DPM) problem, where an update changes the label of a node of a tree with 𝑛 nodes, the state-of-the-art is a dynamic data structure e(𝑛0.6581 ) query and update time via fast matrix multiplication [GH22]. achieving O As dynamic hierarchical data are ubiquitous and SM is important in many applications [ZBT+ 26], we introduce and study two dynamic versions of SM: the Dynamic Subtree Mode (DSM) and the Fully Dynamic Subtree Mode (FDSM) problem. We consider both problems for a leaf-colored tree, but the case where internal nodes are also colored can be reduced to the leaf-colored case easily; see [ZBT+ 26].

1.1

The Dynamic Subtree Mode

Problem (Dynamic Subtree Mode (DSM)). Preprocess a rooted tree T on 𝑛 nodes whose leaves

are colored from a fixed finite universe Δ = {0, . . . , |Δ| − 1}, to support: ⊲ Query Given a node 𝑣, return the most frequent color among the leaves in the subtree of 𝑣. ⊲ Update Given a leaf 𝑣 and 𝑐 ∈ Δ, recolor 𝑣 with 𝑐.

1

DSM models the common setting in which the tree is fixed but the attributes associated with the leaves

(i.e., the colors) evolve. For example, in Figure 1(b) an update changes the color of the leftmost leaf from to . Motivation. From a theoretical standpoint, DSM can be motivated as follows. DSM can be easily reduced to DRM and by using the state-of-the-art data structure for the latter problem, we obtain a baseline with O (𝑛2/3 ) query and update time [EZHMS18]. In addition, there is strong theoretical evidence that these bounds cannot be improved for general DRM by a combinatorial data structure [JX22]. This gives rise to two fundamental questions: (Q1) Can we exploit the tree structure, in which there are 𝑛 instead of 𝑛2 possible queries (ranges), to solve DSM faster than solving it via DRM? (Q2) Can we solve DSM even faster in practical parameter regimes? From a practical standpoint, DSM is motivated by several applications in domains such as computational biology and e-commerce. Annotated phylogenetic trees. In biology, a phylogenetic tree models evolutionary relationships among organisms: leaves represent sampled organisms, while internal nodes represent their common ancestors [WL11]. Leaves can be annotated with categorical metadata such as SNP states, geographic origin, or antibiotic-resistance status [WHN22, SAKK+ 18, ASJ+ 17]. A subtree-mode query at an internal node returns the most prevalent annotation within the corresponding clade, supporting studies of pathogen spread and resistance evolution, as discussed in [ZBT+ 26]. As new laboratory results or revised classifications become available, DSM updates the corresponding leaf colors without changing the phylogenetic tree. E-Commerce product taxonomies. Retailers organize products in a taxonomy tree (e.g., a root-to-leaf path can be Product → Electronics → Audio → Headphones → Apple Airpods 3) [HKP11]. Internal nodes represent product categories, and leaves represent products, each having an attribute, such as rating tier, shipping speed (e.g., Same-Day vs. Standard), supplier, or price tier. By finding the subtree mode of a node 𝑣 corresponding to a category, a retailer can identify the most frequent attribute value of the products in this category. In e-commerce systems, the taxonomy tree is typically curated by experts and is stable, so as to maintain consistent website navigation and SEO indexing, but the product attribute values change frequently [LT23, MR06]. Thus, DSM allows a retailer to update the attribute values and query for the subtree mode, as the attribute values are updated. Example 1.1. A retailer wishes to identify the most frequent product rating category within each category of an e-commerce taxonomy and maintain this information as product ratings evolve. To this end, they construct our DSM data structure on a tree T derived from the Amazon Reviews dataset [MTSvdH15], containing 𝑛 = 863 317 nodes and 859 478 leaves (products), with |Δ| = 5 colors (rating categories). As new reviews arrive, the retailer uses the data structure to maintain the subtree modes under 1 000 rating-category updates, while answering 5 845 subtree mode queries. Processing this workload with DSM is about 71,000 times faster than with the DRM-based baseline.

1.2

The Fully Dynamic Subtree Mode

Problem (Fully Dynamic Subtree Mode (FDSM)). Preprocess a rooted tree T on 𝑛 nodes whose

leaves are colored from a fixed finite universe Δ = {0, . . . , |Δ| − 1}, to support: ⊲ Query Given a node 𝑣, return the most frequent color among the leaves in the subtree of 𝑣. ⊲ Update Given a leaf 𝑣 and 𝑐 ∈ Δ, recolor 𝑣 with 𝑐. ⊲ Add Leaf Given a node 𝑝 and 𝑐 ∈ Δ, add a new child 𝑣 of 𝑝 with color 𝑐. ⊲ Delete Leaf Given a non-root leaf 𝑣, delete 𝑣. ⊲ Link-Cut Update Given a non-root node 𝑢 with parent 𝑝 and a node 𝑣 outside the subtree of 𝑢, replace edge ( 𝑝, 𝑢) by (𝑣, 𝑢).

2

If a deletion or link-cut turns an internal node into a leaf, the operation also specifies a color 𝑐 ∈ Δ for it. FDSM models the setting where, in addition to queries and updates as in DSM, the tree structure is updated. Specifically, a node can be added into T as a leaf, a leaf can be deleted from T , or the subtree rooted at a node 𝑢 of T can be detached and appended under 𝑣. The latter is performed with Link-Cut Update; we do not separate the deletion of the edge ( 𝑝, 𝑢) and the addition of (𝑣, 𝑢) to keep the tree connected. In our example Figure 1(c), an update adds a leaf colored below 𝑣. Finally, in Figure 1(d), a whole subtree is moved by first cutting 𝑢 from its parent and then making 𝑣 its new parent. Also, there is no “Delete Internal Node” operation in FDSM, as it can be performed by the allowed operations of FDSM.1

Motivation. From a theoretical standpoint, FDSM can be motivated as follows: Unlike DSM, where a fixed tree topology allows leaf subtrees to map directly to static array intervals yielding a baseline via DRM, the tree structure updates in FDSM may reorder and split subtrees, making reductions to array range queries inapplicable. At the same time, rebuilding the SM data structure [ZBT+ 26] based on the updated tree after each update incurs a prohibitive O (𝑛) update time. This gives rise to two fundamental questions: (Q3) Can we maintain efficient query and update times when the tree structure is dynamic? (Q4) Can we solve FDSM efficiently in practical parameter regimes? From a practical standpoint, FDSM is motivated by applications in file-system management and network monitoring. File-system hierarchies. Consider a file system in which folders need to be tagged with the most frequent file type (e.g., image, document, source code, etc.) contained in them [ZBT+ 26]. The file system can be modeled as a tree T , in which each non-empty directory is an internal node, its subdirectories are its children, and each file is a leaf that is attached to the node of the containing directory. Furthermore, each leaf is colored according to the type of the file it represents. As discussed in [ZBT+ 26], by finding the subtree mode for a node 𝑣 of T , an administrator can find the most frequent file type in the directory of 𝑣, obtaining useful visual clues about the prevalent contents in the directory. In practice, files are often created or deleted, and files or entire subdirectories may be moved between directories. These changes correspond to leaf insertions, leaf deletions, and subtree moves (link-cut updates), respectively. Thus, FDSM can build a data structure for answering subtree mode queries as the file system evolves. Example 1.2. A file-system administrator wishes to identify the most frequent file type in each directory of a software repository and maintain this information as the repository evolves. To this end, they construct our FDSM data structure on a snapshot of the LLVM Project repository [LLV25], containing 𝑛 = 182 079 nodes, with files assigned to |Δ| = 14 types. As the next 1 000 commits arrive, the administrator uses our data structure to maintain the subtree modes under 695 file and directory additions, deletions, and moves, while answering 12 806 queries on affected directories and their ancestors. Processing this workload with FDSM is about 80 times faster compared to when rebuilding the static SM data structure of [ZBT+ 26] after updates. Prefix aggregation trees. Prefix aggregation trees [FL06, RSBD01] organize IP addresses; internal nodes represent routing prefixes (subnetworks), while leaves represent IP addresses (network endpoints), each colored by a traffic attribute value (e.g., healthy, degraded, or offline, for the service status attribute). Finding the subtree mode for a node 𝑣 allows engineers to identify the predominant traffic attribute value (e.g., service status) in the subnetwork corresponding to the subtree of 𝑣, enabling traffic engineering and automated failover detection. In practice, endpoint subnets join and leave frequently, and subnets are dynamically reassigned to different gateways [KF16, KYA+ 23]. These operations correspond to leaf additions, deletions, and link-cut updates, respectively. Thus, FDSM can build a data structure enabling the tracking of predominant attribute values as the network topology evolves. 1 To delete an internal node 𝑢 without its descendants, we can use Link-Cut Update to move the subtree of each child to 𝑝 and then delete 𝑢 which has become a leaf. To delete both 𝑢 and its descendants, we can apply Delete Leaf to the subtree of 𝑢 bottom-up.

3

1.3

Contributions

In addition to introducing the DSM and FDSM problems, our work makes the following contributions. 1. Optimal and Smooth Trade-off for DSM. We develop an O (𝑛)-space data structure for DSM offering a smooth query/update trade-off: for any trade-off parameter 𝛼 ∈ [0, 1], our data structure supports subtree e(𝑛 𝛼 ) time and leaf color updates in O e(𝑛1− 𝛼 ) time, after O (𝑛)-time preprocessing. We mode queries in O complement this upper bound with a matching conditional lower bound, proving that our trade-off is (conditionally) optimal. This answers question Q1 above in the affirmative and provides strong evidence e( √𝑛) query and update time. that the trade-off cannot be improved. Note that setting 𝛼 = 1/2 yields O This outperforms the aforementioned DRM-based baseline, which cannot be improved for general DRM by a combinatorial data structure [JX22]. See Section 4. 2. Height-Parameterized Analysis of the DSM Data Structure. We prove that our DSM data structure e(1) query admits an analysis parameterized by the height ℎ of the tree T . In this setting, it achieves O e time, O (ℎ) update time, and O (𝑛) construction time and space. This is important because in several DSM applications ℎ is much smaller than 𝑛. For example, large-scale commercial e-commerce product taxonomies have ℎ up to 8 [LDD18a, LDD18b]. See Section 5. 3. Hardness of FDSM. We show that dynamic updates to the tree structure fundamentally limit the achievable efficiency. Specifically, we reduce DRM to FDSM with O (log 𝑛) overhead per operation, so any (combinatorial) FDSM data structure with O (𝑛2/3− 𝜀 ) query and update time contradicts the 𝑛2/3−𝑜 (1) conditional lower bound of [JX22]. Thus, FDSM is inherently as hard as DRM, and question Q3 is answered in the negative for general |Δ|; Contribution 4 shows what is possible when |Δ| is small. See Section 6. 4. Color-Parameterized Data Structure for FDSM. We design an FDSM data structure that is parameterized e(|Δ|) time, while by the number |Δ| of colors. It supports subtree mode queries and link-cut updates in O e color updates and leaf additions/deletions take O (1) time. The data structure can be constructed in e(𝑛) time using O (𝑛) space. This parameterization is important in practice because in many FDSM O applications, |Δ| is much smaller than 𝑛. For example, in file-system hierarchies the number of file types or extensions is clearly much smaller than the number of files. We also show a direct application of our data structure to the Top-1 Document Retrieval problem [Mut02] under document additions [NN17]. See Section 7. 5. Experimental Evaluation. We extensively evaluate our data structures on large, real-world datasets from different domains. For our DSM data structure, we develop an efficient and effective method for configuring the trade-off parameter 𝛼. Our results show that this data structure outperforms the aforementioned DRM-based baseline by up to four orders of magnitude and can be constructed faster on large datasets while maintaining linear space. A case study using data from Amazon [MTSvdH15] further shows a 71,000-fold speedup of our DSM data structure over the DRM-based baseline, and an LLVM case study shows an 80-fold speedup of our FDSM data structure over rebuilding the static SM data structure. See Section 8. The rest of the paper is organized as follows. Section 2 discusses related work and Section 3 provides the necessary background. Section 9 concludes the paper.

2

Related Work

Holistic aggregates in data management. Gray et al. [GCB+ 97] classify aggregates as distributive (e.g., count, sum, min, max), algebraic (e.g., average), and holistic (e.g., the median and the mode). Distributive and algebraic aggregates can be computed by composing constant-size summaries of disjoint data subsets. Thus, standard data structures can maintain such aggregates efficiently, e.g., segment trees over window frames [LKKN15] and sliding-window aggregation for associative operators [THSW15]. For example, distributive/algebraic path and subtree aggregates (e.g., sum, min/max, diameter) on trees can be maintained in O (log 𝑛) time per operation via top trees [AHdLT05] or, for path aggregates, link-cut

4

trees [ST81] and, for subtree aggregates, Euler-tour trees [HK99]. On the other hand, holistic aggregates, such as the mode and percentiles, cannot be determined from bounded-size summaries of subproblems (e.g., a summary from which the mode of a union of subsets can be determined must essentially store the frequency of every color). Thus, such aggregates are fundamentally harder to maintain [GCB+ 97], and, in practice, they are often evaluated from scratch. Database research has studied holistic aggregates over window frames, their incremental view maintenance, and hierarchical data with subtree moves and roll-ups [WX16, VNLK22, PSCP02, BFF+ 15, FBK+ 15, BMK16], but none of these works maintains a holistic aggregate over all subtrees of a hierarchy in sublinear time per update. Static mode queries. As mentioned in Section 1, there has been much work on problems for mode queries in the static setting due to their importance in areas as diverse as databases (e.g., OLAP roll-up aggregations over dimension hierarchies and data profiling) [HKP11, LDD18a], information retrieval [HL23], network engineering [GH22, FL06], and bioinformatics [ZBT+ 26]. Krizanc et al. [KMS05] introduced RM e( √𝑛) query time and and PM. For RM, Chan et al. [CDL+ 14] gave a linear-space data structure with O e(𝑛3/2 ) construction time. They also showed that, under the combinatorial BMM (Boolean Matrix O Multiplication) hypothesis, no combinatorial data structure has both O (𝑛3/2− 𝜀 ) construction time and O (𝑛1/2− 𝜀 ) query time; using fast matrix multiplication, 𝑛 range mode queries can be answered in e(𝑛1.4854 ) total time [VX20]. O Approximate range mode queries too have received attention [BKMT05, GJLT10, HL23]. For PM, e( √𝑛) query time. Recently, the query Durocher et al. [DSST16] gave a linear-space data structure with O e(𝑛3/2 ) construction time [Raţ26]. Since PM generalizes time was improved by a log log 𝑛 factor, with O RM, the conditional lower bound for RM carries over to PM. For SM, on the other hand, the subtree modes of all nodes can be computed in O (𝑛) time [ZBT+ 26], which gives an optimal data structure with O (𝑛) construction time and O (1) query time. Dynamic mode queries. DSM is a special case of DRM, since we can keep the leaves of the tree in DFS order, so that the leaf-descendants of every node form a contiguous array range. A subtree-mode query then becomes a range-mode query, while a leaf recoloring becomes a point update. For DRM, Chan et e(𝑛3/4 ) query time and O e(𝑛3/4 ) amortized expected al. [CDL+ 14] gave a linear-space data structure with O update time. El-Zein et al. [EZHMS18] improved this to O (𝑛2/3 ) worst-case query and update time, using O (𝑛) space and O (𝑛4/3 ) construction time, and additionally support insertions and deletions. Using fast matrix multiplication, Sandlund and Xu [SX20] broke the 𝑛2/3 barrier, and Gu et al. [GPVX21] further improved the query and update time to O (𝑛0.6524 ) using O (𝑛1.3262 ) space. These algebraic data structures are impractical due to the large constants in fast matrix multiplication. Thus, in our experiments, we use the combinatorial data structure of [EZHMS18] as our DRM baseline. On the lower-bound side, Chan et al. [CDL+ 14] reduced the multiphase problem of Pătraşcu [Păt10] to DRM, which gives a polynomial lower bound under the 3SUM hypothesis. Jin and Xu [JX22] showed that, under the combinatorial 4-Clique hypothesis, the O (𝑛2/3 ) bound of El-Zein et al. is optimal for combinatorial data structures up to subpolynomial factors. This shows that the trade-offs we give for DSM with 1/3 < 𝛼 < 2/3 are conditionally impossible for combinatorial DRM data structures. They also observed that the reduction of Chan et al. can be adapted to show an 𝑛1/2−𝑜 (1) lower bound under the Online Matrix-Vector Multiplication (OMv) conjecture, which also applies to algebraic data structures. Our Corollary 4.6 strengthens this: the full query–update trade-off of Theorem 4.2 holds even if all query ranges come from a fixed laminar family; our DSM data structure (Theorem 4.1) shows that this is tight for such families.

3

Preliminaries

We work in the word RAM model with Θ(log 𝑛)-bit words. All trees are rooted, and every node is its own ancestor and descendant. The subtree of a node 𝑣 consists of 𝑣 and its descendants, whereas a subtree of a tree is any connected subgraph, rooted at its shallowest node. For a node 𝑣 of T and a color 𝑐 ∈ Δ, 𝑓𝑣 (𝑐) is the number of leaf-descendants of 𝑣 colored 𝑐, and 𝑓 (𝑐) is this number at the root.

5

Theorem 3.1 (Tree covering [FM14, Theorem 1]). For any integer 1 ≤ 𝐿 ≤ 𝑛, any tree on 𝑛 nodes can be decomposed in O (𝑛) time into O (𝑛/𝐿) subtrees of size O (𝐿) each, which are pairwise disjoint aside from their roots. For each subtree, aside from edges from its root to its children, at most one edge leads from a node of the subtree to a child outside of it. Data Structures. A static tree on 𝑛 nodes supports LCA (lowest common ancestor) queries in O (1) time after O (𝑛)-time preprocessing [BFC00]. Link-cut trees [ST81] maintain a forest of rooted trees on 𝑛 nodes with node values under the following O (log 𝑛)-time operations: making a root a child of a node in another tree, cutting a node from its parent, adding a number to the values of all ancestors of a node, reading a value, and LCA queries. Fine-grained Complexity Hypotheses. An algorithm is combinatorial if it does not use fast matrix multiplication-style techniques; see [HKNS15] for a discussion. The following hypothesis generalizes the combinatorial BMM hypothesis [VW18]. Conjecture 3.2 (Combinatorial 𝑘-Clique Hypothesis [ABV18]). For any constants 𝑘 ≥ 3 and 𝜀 > 0, no combinatorial algorithm detects a 𝑘-clique in an 𝑛-node graph in O (𝑛 𝑘− 𝜀 ) time. 𝛾

Definition 3.3 (𝛾 -OMv [HKNS15]). For a constant 𝛾 > 0 and 𝑛1 = ⌊𝑛2 ⌋, preprocess a Boolean matrix 𝑀 ∈ {0, 1} 𝑛1 ×𝑛2 ; then, for Boolean vectors 𝑣 1 , . . . , 𝑣 𝑛3 ∈ {0, 1} 𝑛2 arriving one by one, output 𝑀𝑣 𝑡 before 𝑣 𝑡+1 arrives. OMv is the special case 𝑛1 = 𝑛2 = 𝑛3 = 𝑛. Conjecture 3.4 (OMv Conjecture [HKNS15]). For any 𝜀 > 0, no algorithm solves OMv in O (𝑛3− 𝜀 ) time with error probability ≤ 1/3. Unlike Conjecture 3.2, Conjecture 3.4 is not restricted to combinatorial algorithms. By a theorem of [HKNS15], Conjecture 3.4 implies hardness for 𝛾 -OMv, meaning that for any 𝛾 > 0, no algorithm with 𝜀 1− 𝜀 1− 𝜀 poly(𝑛1 , 𝑛2 ) preprocessing time solves 𝛾 -OMv in total time O (𝑛1− 1 𝑛2 𝑛3 + 𝑛1 𝑛2 𝑛3 + 𝑛1 𝑛2 𝑛3 ), for a constant 𝜀 > 0, with error probability at most 1/3.

4

DSM: An Optimal Smooth Trade-off

We show that there is a smooth trade-off between the query and update times for the DSM problem. That is, any (polynomial) query time can be achieved, but for smaller query times the update needs to be larger. In Section 4.1, we show how to achieve the precise trade-off and in Section 4.2 that it cannot be improved by a polynomial, by providing a conditional lower bound for DSM.

4.1

The Data Structure

Theorem 4.1, which we prove in this section, presents the construction and operations of our data structure for DSM. e(𝑛 𝛼 ), Theorem 4.1. For any 0 ≤ 𝛼 ≤ 1, there is a data structure for the DSM problem with query time O 1− 𝛼 e(𝑛 update time O ), construction time O (𝑛) and space O (𝑛). 4.1.1 Proof Overview. Fix 0 ≤ 𝛼 ≤ 1. We partition the colors into heavy and light colors based on their frequency such that there are at most 𝑛 𝛼 heavy colors, so their frequencies can be considered explicitly during a query. For every color, we maintain its single-color tree, containing its leaves and only the branching nodes needed to connect them; this permits us to access the frequency of a color at a node of the tree T without storing a color 𝑐 at every ancestor of each leaf colored 𝑐. For light colors, we additionally maintain local frequency information and decompose T into rooted subtrees of size O (𝑛 𝛼 ). This decomposition handles light colors that are not represented at the queried node: if all occurrences of such a color lie in one child subtree, we determine its contribution by local work in a rooted subtree of size O (𝑛 𝛼 ), rather than 6

inspecting all light colors. Below the rooted subtree containing the queried node, we rely on a heap stored at every subtree root, which maintains the most frequent light color below that root. During an update, we explicitly repair these structures only for light colors. Since a light color has frequency less than 𝑛1− 𝛼 , its single-color tree has O (𝑛1− 𝛼 ) nodes, which bounds the update time. We first describe the maintained information and preprocessing. We then give the update and query algorithms, prove their correctness, and finally provide the construction time and space complexity of our data structure. 4.1.2 Maintained Information. We call a color 𝑐 heavy if 𝑓 (𝑐) ≥ 𝑛1− 𝛼 and light otherwise. Write Δ 𝐻 and Δ 𝐿 for the heavy and light colors, respectively. Observe that there are at most 𝑛 𝛼 heavy colors. Write 𝑇𝑐 for the single-color tree for color 𝑐: it is the tree containing all leaves of color 𝑐 and all inner nodes that have leaves of color 𝑐 in at least two of their subtrees (i.e., the virtual tree of the leaves colored 𝑐, which is their closure under lowest common ancestors). By a result from [ZBT+ 26], we can construct all of the single-color trees at once in O (𝑛) time. We will later show how to update them. For every node 𝑣, we will maintain a binary search tree, BST for short, 𝐿𝑇𝑣 that will contain all pairs (𝑐, 𝑓𝑣 (𝑐)) for all light colors 𝑐 such that 𝑣 ∈ 𝑇𝑐 , that is, a BST of all light colors that exist in at least two subtrees of 𝑣 (or, for a leaf 𝑣, its own color if it is light). Heavy colors are not stored in these BSTs; they are handled separately during queries. The sorting of this BST will be in increasing order of frequency (breaking ties with 𝑐), meaning we support the operations get-max, decrease-key, and increase-key in O (log 𝑛) time.2 Additionally, to maintain information on the light colors, we use the tree covering of Theorem 3.1 with 𝐿 = ⌈𝑛 𝛼 ⌉, that is, O (𝑛1− 𝛼 ) subtrees of size O (𝑛 𝛼 ). We assume that we have such a decomposition of T into subtrees and that we store, for every node, the subtrees of the decomposition that contain it (note from the theorem statement that the subtrees overlap only in their roots). In particular, we will maintain lightmode(𝑢), the most common light color in the descendants of 𝑢, for all roots of all these subtrees. To this end, we let the subtree roots cut T into regions. The region 𝑆(𝑟) of a subtree root 𝑟 consists of 𝑟 and all descendants of 𝑟 that are not subtree roots and are reached from 𝑟 without passing through another subtree root. The child roots of 𝑟 are the first subtree roots below 𝑟 (i.e., the subtree roots 𝑟 ′ ≠ 𝑟 such that the path from 𝑟 to 𝑟 ′ contains no further subtree root). Thus, the subtree of 𝑟 splits into the region 𝑆(𝑟) and the subtrees of the child roots of 𝑟. Intuitively, the heap 𝐴𝐺 𝑟 summarizes the subtree of 𝑟 by combining the best light candidate of every node in its region with the summaries of its child roots. Concretely, 𝐴𝐺 𝑟 contains (1) one entry get-max (𝐿𝑇𝑢 ) for every 𝑢 ∈ 𝑆(𝑟) and (2) one entry get-max ( 𝐴𝐺 𝑟 ′ ) for every child root 𝑟 ′ of 𝑟, and it supports the same operations as the 𝐿𝑇𝑣 . Let lightmode(𝑟) be the color of get-max ( 𝐴𝐺 𝑟 ). Every node lies in exactly one region and every subtree root is a child root of at most one subtree root, so these heaps take O (𝑛) space in total. Now, lightmode(𝑟) is indeed a most frequent light color below 𝑟: as the subtree of 𝑟 splits into 𝑆(𝑟) and the subtrees of its child roots, induction over the child roots shows that get-max ( 𝐴𝐺 𝑟 ) is exactly this entry. The heaps can be initialized bottom-up in linear time once the 𝐿𝑇𝑣 are built. 4.1.3 Update. We state the update procedure in Algorithm 1. We should explain how to update 𝑇𝑐 and 𝑇𝑑 , the single-color trees of the old color 𝑐 and the new color 𝑑, respectively. Let us look at the update of 𝑇𝑐 first. Here, 𝑣 is a leaf that is now not colored 𝑐 anymore, thus we simply delete it from 𝑇𝑐 . Additionally, this might make the parent 𝑝 of 𝑣 in 𝑇𝑐 not be branching anymore, forcing us to delete it from 𝑇𝑐 . This cannot cascade: if 𝑝 is deleted, the subtree of 𝑝 still contains leaves colored 𝑐, so every ancestor of 𝑝 in 𝑇𝑐 still has leaves colored 𝑐 in the same subtrees as before. We also need to decrease the value of 𝑓𝑢 (𝑐) for all ancestors 𝑢 of 𝑣 in 𝑇𝑐 . This can be done via 2 There are many standard data structures that can give us these operations, one example being the “humble” heap [CLRS22, Section 6.5].

7

Algorithm 1: Update(𝑣, 𝑐 → 𝑑): recolor leaf 𝑣 from 𝑐 to 𝑑 and restore all maintained information. Input: Leaf 𝑣 whose color changes from 𝑐 to 𝑑 ▶ Step 1: update the single-color trees Update 𝑇𝑐 and 𝑇𝑑 and the frequencies of 𝑐 and 𝑑 at their nodes using link-cut trees ▶ Step 2: maintain the BSTs of light colors per node if 𝑐 ∈ Δ 𝐿 then foreach ancestor 𝑢 of 𝑣 in 𝑇𝑐 do decrease-key for 𝑐 in 𝐿𝑇𝑢 Delete 𝑐 from 𝐿𝑇𝑢 for the O (1) nodes removed from 𝑇𝑐 if 𝑑 ∈ Δ 𝐿 then Insert (𝑑, 𝑓𝑢 (𝑑)) into 𝐿𝑇𝑢 for the O (1) new nodes in 𝑇𝑑 foreach ancestor 𝑢 of 𝑣 in 𝑇𝑑 not added in Step 1 do increase-key for 𝑑 in 𝐿𝑇𝑢 if 𝑐 becomes light then Remove 𝑐 from Δ 𝐻 , add to Δ 𝐿 foreach 𝑢 in 𝑇𝑐 do // O ( 𝑓 (𝑐)) ⊆ O (𝑛1− 𝛼 ) many Insert (𝑐, 𝑓𝑢 (𝑐)) into 𝐿𝑇𝑢 if 𝑑 becomes heavy then Add 𝑑 to Δ 𝐻 , remove from Δ 𝐿 foreach 𝑢 in 𝑇𝑑 do // O ( 𝑓 (𝑑)) ⊆ O (𝑛1− 𝛼 ) many Delete 𝑑 from 𝐿𝑇𝑢 ▶ Step 3: update the heaps of subtree roots Update the entry of every node 𝑢 whose 𝐿𝑇𝑢 changed in Step 2 in the heap 𝐴𝐺 𝑟 with 𝑢 ∈ 𝑆(𝑟) foreach subtree root 𝑟 ′ whose heap 𝐴𝐺 𝑟 ′ changed, in order of decreasing depth do Update the entry of 𝑟 ′ in 𝐴𝐺 𝑟 , for every child root 𝑟 ′ of 𝑟

a path-update in the link-cut tree. The operation for updating 𝑇𝑑 is almost symmetric; the only difference is that the counterpart of deleting the parent of 𝑣 in 𝑇𝑐 is slightly more difficult. In particular, a new internal node might appear in 𝑇𝑑 (as the parent of 𝑣) if there is another leaf 𝑣 ′ s.t. the lowest common ancestor of 𝑣 and 𝑣 ′ is not already in 𝑇𝑑 . To find it, we maintain, for every color, its leaves in DFS order in a BST. Let 𝑣 ′ and 𝑣 ′′ be the predecessor and successor of 𝑣 among the leaves colored 𝑑 in this order. The only candidate for the new internal node (and the parent of 𝑣 in 𝑇𝑑 ) is the deeper of the lowest common ancestors (LCA) of 𝑣, 𝑣 ′ and of 𝑣, 𝑣 ′′ , so two LCA queries suffice. Thus, 𝑇𝑐 and 𝑇𝑑 change by only O (1) nodes. If the candidate 𝑥 is not yet in 𝑇𝑑 , let 𝑦 be the topmost node of 𝑇𝑑 in the subtree of 𝑥, found as in Section 4.1.4 before 𝑣 is inserted into the DFS-order BST; we splice 𝑥 in between 𝑦 and the parent of 𝑦 in 𝑇𝑑 with 𝑓 𝑥 (𝑑) := 𝑓 𝑦 (𝑑), make 𝑣 a child of 𝑥, and add 1 to 𝑓𝑢 (𝑑) for all ancestors 𝑢 of 𝑣 in 𝑇𝑑 by a path-update. This takes O (1) link-cut operations. For the running time, note that Steps 2 and 3 touch only light colors; heavy colors only need the O (log 𝑛)-time path-updates of Step 1. A light color 𝑐 satisfies 𝑓 (𝑐) < 𝑛1− 𝛼 , so 𝑇𝑐 has O (𝑛1− 𝛼 ) nodes. The same holds when a color crosses the heavy/light threshold, as its frequency then is at most 𝑛1− 𝛼 + 1. Hence, Step 2 changes O (𝑛1− 𝛼 ) BSTs, each in O (log 𝑛) time. In Step 3, every one of the O (𝑛1− 𝛼 ) subtree e(𝑛1− 𝛼 ) time. roots is handled at most once, after all changes to its heap. Thus, an update takes O 4.1.4 Query. For the query procedure, see Algorithm 2. First, note how we can access 𝑓𝑣 (𝑐). If 𝑣 ∈ 𝑇𝑐 , we have directly stored the value. Otherwise, let 𝑢 be the topmost node of 𝑇𝑐 in the subtree of 𝑣; by the definition of 𝑇𝑐 , 𝑓𝑣 (𝑐) = 𝑓𝑢 (𝑐), or 𝑓𝑣 (𝑐) = 0 if 𝑢 does not exist. We find 𝑢 as the LCA of the first and the last leaf colored 𝑐 in the subtree of 𝑣, which two searches in the DFS-order BST of Section 4.1.3 provide, in O (log 𝑛) time. To complete the explanation, we must explain how to compute lightmode. For a subtree root 𝑣, we directly take the value lightmode(𝑣) we maintained during updates. For any non-root node 𝑢, it will be computed recursively. That is, we take the maximum of get-max (𝐿𝑇𝑢 ) and

8

lightmode(𝑤) over all children 𝑤 of 𝑢. Note that this will then be executed at most once per node that is in the subtree of 𝑢 (which is unique as 𝑢 is not a subtree root). By Theorem 3.1, this recurses at most O (𝑛 𝛼 ) times in total. Moreover, each call takes O (1) time per child of its node. All children of these nodes lie in the same subtree of the decomposition, except for at most one child in total by Theorem 3.1; as the parent of this child is not a subtree root, the child must be the root of its subtree, so we take its stored value in O (1) time. Hence, computing lightmode(𝑣) takes O (𝑛 𝛼 ) time. It remains to see why the query returns a most frequent color below 𝑣. For the heavy colors, this is immediate, as we check all of them explicitly. For the light colors, recall from Section 4.1.2 that a most frequent light color 𝑥 below 𝑣 is stored with its full frequency at the topmost node 𝑢 of 𝑇𝑥 in the subtree of 𝑣, and that no entry exceeds the true frequency of its color below 𝑣. Thus, it suffices that the query accounts for 𝐿𝑇𝑢 . Indeed, the computation of lightmode(𝑣) descends from 𝑣 towards 𝑢 and reaches 𝑢 or stops at a subtree root on the path from 𝑣 to 𝑢 (possibly 𝑣), whose heap accounts for 𝐿𝑇𝑢 . Note that this includes the case 𝑢 = 𝑣, where the leaves colored 𝑥 below 𝑣 branch at 𝑣: then 𝐿𝑇𝑣 is taken into account either directly by the recursion or, if 𝑣 is a subtree root, through 𝐴𝐺 𝑣 , as 𝑣 ∈ 𝑆(𝑣). Thus, we do not need to consult 𝐿𝑇𝑣 separately. Algorithm 2: Query(𝑣): report a most frequent color among the leaves below 𝑣. Input: Node 𝑣 ▶ Step 1: best light color, via the tree decomposition 𝑎 ← lightmode(𝑣) ▶ Step 2: best heavy color, by checking all of them 𝑏 ← arg max𝑐∈Δ𝐻 𝑓𝑣 (𝑐) return the one of 𝑎 and 𝑏 with larger 𝑓𝑣

// O (𝑛 𝛼 ) // O (|Δ 𝐻 |) ⊆ O (𝑛 𝛼 )

4.1.5 Construction Time and Space. Preprocessing begins by running the algorithm from [ZBT+ 26] on all colors. This also gives us the initial 𝑇𝑐 ’s and the LCA data structure (see Section 3). Then we transform these 𝑇𝑐 ’s into link-cut trees (see [ST81]), build the DFS-order BSTs of Section 4.1.3 by sorting the leaves of each color by DFS number, build the heaps 𝐿𝑇𝑣 and 𝐴𝐺 𝑟 bottom-up, and compute the decomposition from Theorem 3.1. All of this can be done in O (𝑛) time using O (𝑛) space [ZBT+ 26, ST81].

4.2

The Lower Bound

Techniques from fine-grained complexity allow us to show that we cannot significantly improve on the data structure we presented in Section 4.1, unless central hardness assumptions fail. Specifically, we provide the following theorem, which rules out a polynomial improvement to the tradeoff between update and query time. Theorem 4.2. For any 𝛼 ∈ (0, 1), if there is a data structure for the DSM problem with polynomial e(𝑛 𝛼− 𝜀𝑄 ) and update time O e(𝑛1− 𝛼− 𝜀𝑈 ) for some 𝜀 𝑄 , 𝜀𝑈 ≥ 0 with 𝜀 𝑄 +𝜀𝑈 > 0, preprocessing, query time O then the OMv conjecture fails. Proof. We reduce 𝛾 -OMv to DSM and assume that we have access to a DSM data structure violating Theorem 4.2. If the input matrix is 𝑀 ∈ {0, 1} 𝑛1 ×𝑛2 , then the reduction builds a single tree 𝑇 of size 𝑛 = Θ(𝑛1 𝑛2 ) during preprocessing and, in each OMv round, performs a controlled number of updates and queries. We choose 𝛾 based on 𝛼 and the alleged running time improvements 𝜀𝑈 , 𝜀 𝑄 and thus derive a contradiction for every 𝛼. Concretely, we pick any 𝛾 such that 𝛼 − 𝜀𝑄 <

1 < 𝛼 + 𝜀𝑈 . 1+𝛾

As one of 𝜀 𝑄 , 𝜀𝑈 is greater than 0 and 𝛼 ∈ (0, 1), such a 𝛾 > 0 exists. Ô Recall that by definition (𝑀𝑣)𝑖 = 𝑗 (𝑀𝑖, 𝑗 ∧ 𝑣 𝑗 ). 9

𝑀=

1 0 1 0 1 0 1 1 0

!

𝑣 = (0, 1, 0) 𝑤𝑀𝑣 = (0, 1, 1)

𝑤3

2

𝑤1

1 2 𝑀3

1 3 2 2 1 3 𝑀2 𝑀2 𝑀1 𝑀1

4 2 6 𝑢1 𝑢2 𝑢3

Figure 2: The tree of the reduction for the shown 𝑀 and 𝑣, after loading 𝑣. Leaves show their colors; placeholder colors are gray and the recolored leaf 𝑢 2 is highlighted. The shaded regions mark the leaves encoding the rows of 𝑀 and the vector 𝑣. Construction First, let us define, for each 𝑖 ∈ [𝑛1 ], the sets 𝑀𝑖 and 𝑀𝑖 as the sets of indices 𝑗 ∈ [𝑛2 ] such that 𝑀𝑖, 𝑗 = 1 and the complement of that set, respectively. That is, the indices of the one and zero bits in row 𝑖, respectively. We create leaves for each element of each of the sets 𝑀𝑖 and 𝑀𝑖 .3 Call these leaves the matrix leaves (we will later also describe vector leaves to encode the queried vector 𝑣). Each of these sets has a special parent node 𝑤 𝑀𝑖 and 𝑤 𝑀𝑖 (which we omit if the set is empty). For each row 𝑖 ∈ [𝑛1 ] \ {1}, create a node 𝑤 𝑖 that has as children: (1) the node 𝑤 𝑀𝑖 , (2) the node 𝑤 𝑖−1 , (3) the node 𝑤 𝑀𝑖−1 . The node 𝑤 1 only has the first of these and the vector leaves we describe later. The root of the tree is 𝑤 𝑛1 . See Figure 2 for an example. Now, the following observation is crucial for our analysis. Observation 4.3. For each 𝑖 ∈ [𝑛1 ] and 𝑗 ∈ [𝑛2 ], the number of descendants of 𝑤 𝑖 colored 𝑗 among the matrix leaves is 𝑓𝑤𝑖 ( 𝑗) = 𝑖 − 1 + 𝑀𝑖, 𝑗 . Additionally, we create 𝑛2 children of 𝑤 1 , we name them 𝑢 𝑗 (for each 𝑗 ∈ [𝑛2 ]). These are the vector leaves and, initially, these are each colored with a unique color (i.e., one that appears nowhere else in the tree), for example 𝑛2 + 𝑗. On this leaf-colored tree, call the preprocessing of the alleged DSM data structure. When we get a query 𝑣 ∈ {0, 1} 𝑛2 , we do the following for each 𝑗 ∈ [𝑛2 ] such that 𝑣 𝑗 = 1: we color the node 𝑢 𝑗 with color 𝑗. If 𝑣 𝑗 = 0, we color the node with its placeholder color 𝑛2 + 𝑗. We call this operation loading 𝑣; it is possible using at most 𝑛2 updates to our alleged DSM data structure. Now, this together with the previous observation yields the following result. OMv Query

Corollary 4.4. After loading 𝑣, and for every 𝑖 ∈ [𝑛1 ], the frequency of the subtree mode of 𝑤 𝑖 is 𝑖 + 1 iff there is a 𝑗 ∈ [𝑛2 ] such that (1) 𝑀𝑖, 𝑗 = 1, and (2) 𝑣 𝑗 = 1. Otherwise, that frequency is 𝑖 − 1 or 𝑖. Note that this is exactly the condition for (𝑀𝑣)𝑖 = 1. From this corollary, we immediately get that we can extract the vector 𝑀𝑣 using 𝑛1 queries to our alleged DSM data structure. Call this operation reading 𝑀𝑣. Size and Running Times It is easy to see that we have at most 𝑛1 𝑛2 + 𝑛2 leaves in this tree. As there are only O (𝑛1 ) inner nodes, there are at most O (𝑛1 𝑛2 ) nodes in total. Write 𝑛 for this number of nodes. As this is polynomial in 𝑛1 𝑛2 and the preprocessing of our alleged DSM data structure is polynomial in its input, the total OMv preprocessing is also polynomial. 3 Technically, we omit this for 𝑀

𝑛1 .

10

Now, let us consider the total time to process 𝑛3 OMv queries. While servicing each OMv query, we make 𝑛2 updates to the alleged DSM data structure and 𝑛1 queries. By assumption, this takes a total of O (𝑛3 𝑛1 𝑛 𝛼− 𝜀𝑄 + 𝑛3 𝑛2 𝑛1− 𝛼− 𝜀𝑈 ) (1+𝛾) ( 𝛼− 𝜀𝑄 )+𝛾

=O (𝑛3 𝑛2

(1+𝛾) (1− 𝛼− 𝜀𝑈 )+1

+ 𝑛3 𝑛2

). 1+𝛾

Deriving the contradiction Computing 𝑛3 products of type 𝑀𝑣 naively costs Θ(𝑛1 𝑛2 𝑛3 ) = Θ(𝑛3 𝑛2 ); by the hardness of 𝛾 -OMv (Section 3), no algorithm with polynomial preprocessing beats this by a polynomial factor. Simple rearrangement shows our reduction does exactly that, (i.e., that both exponents above are strictly below 1 + 𝛾). For the query term, (1 + 𝛾) (𝛼 − 𝜀 𝑄 ) + 𝛾 < 1 + 𝛾

⇐⇒

𝛼 − 𝜀𝑄 <

1 , 1+𝛾

and for the update term, (1 + 𝛾) (1 − 𝛼 − 𝜀𝑈 ) + 1 < 1 + 𝛾

⇐⇒

1 < 𝛼 + 𝜀𝑈 . 1+𝛾

Thus, the existence of the alleged data structure violates the OMv conjecture. Remark 4.5. This reduction uses that the DSM data structure returns the frequency of the subtree mode when queried. This is not a restriction as such a data structure can be derived from one that only reports the color of the subtree mode with only additive extra logarithmic running time in both the query and update. To achieve this, maintain the single-color trees and the DFS-order BSTs of Section 4.1.3, which takes O (log 𝑛) time per update, and compute 𝑓𝑣 (𝑐) for the reported color 𝑐 as in Section 4.1.4, in O (log 𝑛) time. □ Corollary 4.6. Theorem 4.2 also holds for DRM with array length 𝑛, where point updates change the color of one element, and all query ranges come from a fixed laminar family of intervals. Proof. Order the leaves of the tree constructed above in DFS order and let 𝐴 be the array of their colors, so that | 𝐴| = Θ(𝑛). The leaf-descendants of every node 𝑣 then form an interval [𝐿 𝑣 , 𝑅𝑣 ] of 𝐴, and these intervals form a laminar family, as two subtrees are either disjoint or nested. A leaf recoloring is a point update of 𝐴 and a subtree mode query at 𝑣 is a range mode query on [𝐿 𝑣 , 𝑅𝑣 ]. Thus, a DRM data structure violating the bounds of Theorem 4.2 on this family yields a DSM data structure violating them on our instances, contradicting the OMv conjecture. □

5

Low Tree Height Can Improve DSM

In several of the applications for DSM, the underlying trees have very small height (see Section 1). For instance, in the applications presented in [ZBT+ 26], the input trees are suffix trees of string collections, and suffix trees are known to have a small height for certain string distributions [DSR92]. It is thus natural to ask if our DSM data structure can be improved in this case. Interestingly, the construction from Section 4.1 can be reanalyzed in this case to give tighter bounds. e(1), Theorem 5.1. There is a data structure for the DSM problem for trees of height ℎ with query time O e(ℎ), construction time O (𝑛) and space O (𝑛). update time O

11

Proof. This follows directly from our data structure in Section 4.1 when we treat all colors as light (this means we set 𝛼 = 0; as a tree with 𝑛 ≥ 2 nodes has fewer than 𝑛 leaves, no color is heavy). It directly e(1). For the update time, we examine follows from that section that the query time then becomes O Algorithm 1 again. First observe that the conditional operations for when a color changes between light and heavy will never trigger as all colors are always light. Second, observe that the updates in Step e(1) time anyways. Lastly, observe that the remaining loops (in Step 2 and 3) run for 1 only require O each ancestor of the changed node, thus at most ℎ times, as only BSTs and heaps of ancestors of the changed node change. Each operation performed inside a loop iteration is logarithmic, giving the desired bound. □ In Section 7, we show an application that specifically utilizes suffix trees in another special case: FDSM with small |Δ|.

e(1) query Remark 5.2. The instances of Section 4.2 have height Θ(𝑛1 ). Hence, a data structure with O 1− 𝜀 e(ℎ ) update time, for some 𝜀 > 0, processes each OMv round, that is, 𝑛2 updates and 𝑛1 time and O e(𝑛2 𝑛1− 𝜀 + 𝑛1 ) time. By the hardness of 𝛾 -OMv (Section 3), this violates the OMv conjecture queries, in O 1 for any 𝛾 > 0. This means that the update time of Theorem 5.1 cannot be improved by a polynomial unless OMv fails.

6

Why Is the Connectivity Not Dynamic?

The allowed update operations of the data structure presented in the previous section do not allow the structure of the tree to change. It is thus natural to ask if there is a data structure that allows, for example, the insertion and deletion of edges. To ensure that the tree remains connected, such updates are frequently modeled as the addition and deletion of leaves together with the Link-Cut operation described in the definition of FDSM. The following theorem shows that if we allow such operations, we run into a well-known barrier: such a data structure would directly yield a data structure for the dynamic range mode problem DRM. e(𝑇 (𝑛)), Theorem 6.1. If there is a data structure for the FDSM problem with query and update time O then there is such a data structure for DRM. If the FDSM data structure is combinatorial, then so is the derived DRM one. Proof. Consider a DRM instance with an array 𝐴 of length 𝑛 over the color set Δ. For initialization, create 𝑛 leaves 𝑎 1 , . . . , 𝑎 𝑛 and color each 𝑎 𝑖 with 𝐴[𝑖]. Also create 𝑛 inner nodes 𝑢 1 , . . . , 𝑢 𝑛 , where 𝑢 𝑛 is the parent of 𝑎 𝑛 only and all other 𝑢 𝑖 are parent of 𝑢 𝑖+1 and 𝑎 𝑖 . Thus, for every 𝑖 ∈ [𝑛], the leaf descendants of 𝑢 𝑖 are exactly 𝑎 𝑖 , . . . , 𝑎 𝑛 . Finally, create a root 𝑣 1 as the parent of 𝑢 1 . For a DRM query 𝑖, 𝑗 with 𝑖 ≤ 𝑗, map it to a constant number of FDSM operations as follows: if 𝑗 < 𝑛, cut 𝑢 𝑗+1 from its parent 𝑢 𝑗 and attach it to 𝑣 1 . Now (also if 𝑗 = 𝑛) the leaf descendants of 𝑢 𝑖 are exactly 𝑎 𝑖 , . . . , 𝑎 𝑗 , so that the subtree mode of 𝑢 𝑖 is exactly the desired range mode. Afterwards, undo the link-cut operation so that the topology of the tree is the same as initially. For a DRM update that changes an entry, recolor 𝑎 𝑖 . To insert or delete an entry, create or delete the corresponding 𝑎 𝑖 and 𝑢 𝑖 ; as 𝑢 𝑖 lies on the path 𝑢 1 , . . . , 𝑢 𝑛 , this takes a constant number of leaf additions/deletions and Link-Cut Updates. Note that the indices of leaves and internal nodes change, since inserting or deleting an entry shifts all later positions. To find the nodes belonging to a position, we keep the pairs (𝑎 𝑖 , 𝑢 𝑖 ) in array order in a balanced search tree, which costs O (log 𝑛) time per operation. In conclusion, every DRM operation boils down to a constant number of FDSM operations on a tree e(𝑇 (𝑛)). with O (𝑛) nodes, plus O (log 𝑛) time for the search tree. This gives query and update time O Initialization only adds linear time to the construction of the FDSM data structure. Finally, the reduction uses the FDSM data structure as a black box, so it is combinatorial if the FDSM data structure is. □

12

Note that Theorem 6.1 yields hardness for FDSM only in combination with a lower bound for DRM. For combinatorial data structures, a tight conditional lower bound is due to Jin and Xu [JX22]. This matches the O (𝑛2/3 ) upper bound of El-Zein et al. [EZHMS18] up to subpolynomial factors. Setting 𝑇 (𝑛) = 𝑛2/3− 𝜀 in Theorem 6.1, together with these conditionally tight bounds, gives the following. Corollary 6.2. Under the combinatorial 4-Clique hypothesis (Conjecture 3.2 with 𝑘 = 4), there is no combinatorial FDSM data structure with polynomial preprocessing time and O (𝑛2/3− 𝜀 ) query and update time for any 𝜀 > 0. e(𝑛2/3− 𝜀 ) ⊆ O (𝑛2/3− 𝜀/2 ), Corollary 6.2 also rules out O e(𝑛2/3− 𝜀 ) query and update time. The Since O restriction to combinatorial data structures is essential for this argument. Using fast matrix multiplication, Gu et al. [GPVX21] obtain a DRM data structure with O (𝑛0.6524 ) query and update time, so Theorem 6.1 does not preclude an algebraic FDSM data structure with O (𝑛2/3− 𝜀 ) query and update time. Still, any FDSM data structure with O (𝑛0.6524− 𝜀 ) query and update time would improve the state of the art for DRM.

7

Few Colors Allow FDSM

Motivated by the hardness result from the previous section, we ask if there can exist efficient data structures for FDSM for important special cases. As discussed in Section 1, in several applications of FDSM, |Δ| is much smaller than 𝑛. In this section, we will tolerate algorithms that have linear overhead in |Δ|. We e(1) show that there is a linear-space FDSM data structure where every operation costs O (log2 𝑛) = O 2 e or O (|Δ| log 𝑛) = O (|Δ|) worst-case time. The structure consists of one dynamic Euler sequence and per-color search trees ordered through it. There is no polynomial dependence on 𝑛, which helps the aforementioned applications, where |Δ| ≪ 𝑛. Theorem 7.1. There is an FDSM data structure of size O (𝑛) which can be constructed in O (𝑛 log 𝑛) time, with the following worst-case operation times: • Query (query the subtree mode of a node): O (|Δ| log2 𝑛) time • Update (change the color of a leaf): O (log2 𝑛) time • Link-Cut Update (link and cut a subtree, moving all its vertices): O (|Δ| log2 𝑛) time • Add/Delete Leaf (adding or deleting a leaf): O (log2 𝑛) time Proof. Representation and order comparisons. We choose an arbitrary order of the children of every node and maintain the corresponding Euler sequence 𝐸. For every vertex 𝑣, the sequence contains an entry token 𝑒 𝑣 and an exit token 𝑥 𝑣 . The interval from 𝑒 𝑣 through 𝑥 𝑣 consists exactly of the tokens of the subtree rooted at 𝑣. We store 𝐸 in a worst-case balanced sequence tree with parent pointers and subtree sizes, supporting insertion, deletion, splitting, concatenation, and the rank of a token in O (log 𝑛) time. Each vertex has handles to its two tokens. For every color 𝑐 currently present on a leaf, we maintain a balanced search tree 𝐵𝑐 containing the entry tokens of exactly the leaves of color 𝑐, in their order in 𝐸. Each 𝐵𝑐 stores subtree sizes and supports order-statistic searches, insertion, deletion, splitting at a search position, and concatenation of ordered trees. A balanced dictionary maps the currently present colors to their trees; it takes O (𝑛) space and O (log 𝑛) time per lookup. Empty color classes need no permanent record. We also store parent pointers and child counts in the underlying rooted tree. To compare two keys of 𝐵𝑐 , we compare their current ranks in 𝐸. This costs O (log 𝑛) time, so a search or a split located by such comparisons takes O (log2 𝑛) time. Once the relevant handles or split positions are known, the structural balanced-tree operations take O (log 𝑛) time. In particular, we do not assume constant-time comparisons of positions in a sequence undergoing subtree moves. The order of a color tree remains valid whenever the relative Euler order of its keys is preserved; absolute ranks need not be stored or updated. 13

Query. For a token 𝑎, let 𝑟 𝑐 (𝑎) be the number of keys of 𝐵𝑐 strictly preceding 𝑎 in 𝐸. The leaf-color frequency in the subtree of 𝑣 is 𝑓𝑣 (𝑐) = 𝑟 𝑐 (𝑥 𝑣 ) − 𝑟 𝑐 (𝑒 𝑣 ). Indeed, precisely the colored leaf-entry tokens of that subtree lie in this interval, including 𝑒 𝑣 itself when 𝑣 is a leaf. Two order-statistic searches compute this difference in O (log2 𝑛) time. An absent color has frequency zero. Iterating over the nonempty color classes and returning one of maximum frequency therefore takes O (|Δ| log2 𝑛) time. Recoloring. To recolor a leaf 𝑤 from 𝑐 to 𝑑, delete 𝑒 𝑤 from 𝐵𝑐 and insert it into 𝐵 𝑑 , creating or removing dictionary records when necessary. The Euler sequence is unchanged, and no other color tree is affected. This takes O (log2 𝑛) time. Add/Delete Leaf. To attach a new leaf 𝑤 to 𝑝, insert 𝑒 𝑤 , 𝑥 𝑤 immediately before 𝑥 𝑝 , choosing 𝑤 as the last child of 𝑝, and insert 𝑒 𝑤 into the search tree for its color. If 𝑝 was a leaf, first remove 𝑒 𝑝 from the search tree for its old color: 𝑝 is now internal and contributes no leaf color. To delete a non-root leaf 𝑤, remove its color record and its two Euler tokens. If its parent becomes a leaf, insert the parent’s entry token into the tree for the color specified by the operation. Each operation changes only constantly many color records. Insertion or deletion of Euler tokens preserves the relative order of all surviving tokens, so all other color trees remain valid without modification. Both operations take O (log2 𝑛) time, independently of |Δ|. Link-Cut Update. Let 𝑝 be the old parent of 𝑢, and let 𝑣 lie outside the subtree of 𝑢. If 𝑣 = 𝑝, the update changes nothing. If 𝑣 is a leaf, it becomes internal, so we first delete 𝑒 𝑣 from the search tree of its color in O (log 𝑛) time. Let 𝐼 = [𝑒 𝑢 , 𝑥𝑢 ] be the Euler interval to be moved. For each currently represented color 𝑐, use two searches and splits to factor 𝐵𝑐 into the keys before 𝐼, the keys in 𝐼, and the keys after 𝐼. Save the middle tree 𝐶𝑐 and concatenate the other two trees to obtain 𝑅𝑐 . Keep the temporary color records until the update is complete, even if 𝑅𝑐 is empty. All these extractions are performed before changing 𝐸. Next, cut 𝐼 out of 𝐸 and insert it immediately before 𝑥 𝑣 , making 𝑢 the last child of 𝑣. This uses constantly many sequence splits and concatenations and takes O (log 𝑛) time. The keys of each 𝑅𝑐 retain their relative order, as do the keys of each 𝐶𝑐 , so both remain valid search trees under the new Euler order. For each 𝑐, split 𝑅𝑐 at 𝑥 𝑣 in this new order and concatenate its first part, 𝐶𝑐 , and its second part. Every key of 𝐶𝑐 now belongs between those two parts: the moved interval immediately precedes 𝑥 𝑣 , and no key of 𝑅𝑐 lies inside that interval. This reconstructs 𝐵𝑐 in O (log2 𝑛) time per color. Finally update the underlying parent pointers and child counts. If 𝑝 has become a leaf, insert 𝑒 𝑝 with the color supplied by the operation; discard any empty color records. These boundary changes cost O (log2 𝑛) time in total. Thus a link-cut update takes O (|Δ| log2 𝑛) time. The two-phase procedure is essential: searching unprocessed color trees after moving 𝐼 could otherwise use an invalid key order. Unary-node insertion and removal. We will also use a simple extension in the applications below. To subdivide an edge leading to 𝑢 with a new unary node 𝑧, insert 𝑒 𝑧 immediately before 𝑒 𝑢 and 𝑥 𝑧 immediately after 𝑥 𝑢 . The new node is internal, and no existing leaf changes status or relative Euler order, so no color tree changes. Removing a unary node is the reverse operation. Each costs O (log 𝑛) time. The same argument allows a new unary root to be inserted or removed. Space, construction, and worst-case bounds. The sequence tree has 2𝑛 tokens, and the total number of records in all color trees is exactly the number of leaves, at most 𝑛. The dictionary, underlying-tree records, and temporary trees used during a move also occupy O (𝑛) space: splitting and concatenation rearrange existing color records rather than copying them. Hence the total space is O (𝑛). For construction, traverse the initial tree in Euler order, build 𝐸, and append each leaf-entry token to the list for its color, locating these lists through the balanced color dictionary. This takes O (𝑛 log 𝑛) time; each list is already sorted in Euler order and can be converted into its balanced search tree in linear time in its length. All stated operation bounds are worst-case when worst-case balanced sequence and search trees are used. □ In Appendix A, we show a direct application of Theorem 7.1 to the Top-1 Document Retrieval problem

14

under document additions. The same representation directly supports the frequency of a specified color. The two order-statistic searches in the proof of Theorem 7.1 give the following corollary. Corollary 7.2. There is a data structure of size O (𝑛) that returns the frequency of a specified color 𝑐 among the leaf descendants of a queried node 𝑣 in O (log2 𝑛) worst-case time. Recolorings and leaf insertions/deletions take O (log2 𝑛) time, while link-cut updates take O (|Δ| log2 𝑛) time. To compare our two data structures, note that log2 𝑛 = 𝑜(𝑛1− 𝛼 ) for every fixed 0 < 𝛼 < 1. Corollary 7.3. The data structure of Theorem 7.1 has asymptotically faster color updates than the data structure of Theorem 4.1 for any fixed 0 < 𝛼 < 1. It also has asymptotically faster queries whenever |Δ| log2 𝑛 = 𝑜(𝑛 𝛼 ). Corollary 7.4. Combined with the reduction of Theorem 6.1 and the unary-node extension in the proof of Theorem 7.1, our construction yields a linear-space combinatorial DRM data structure with query time O (|Δ| log2 𝑛) and update time O (log2 𝑛). These update bounds are asymptotically smaller than the O (𝑛2/3 ) bound of the state-of-the-art combinatorial DRM data structure [EZHMS18] for every Δ; the query bound is asymptotically smaller if and only if |Δ| = 𝑜(𝑛2/3 /log2 𝑛). Proof. Use the tree representation from Theorem 6.1 on O (𝑛) nodes. Each range query requires constantly many subtree moves and one subtree-mode query. An entry recoloring requires one leaf recoloring. Inserting or deleting an entry additionally requires constantly many leaf insertions/deletions and insertion or removal of a unary node. The unary-node extension proved above costs O (log 𝑛) time and changes no color search tree. The balanced search tree mapping array positions to vertices adds O (log 𝑛) time per operation. Hence queries take O (|Δ| log2 𝑛) time and updates take O (log2 𝑛) time, in O (𝑛) space. The construction uses only comparisons and balanced-tree operations, so it is combinatorial. Finally, log2 𝑛 = 𝑜(𝑛2/3 ), and comparing |Δ| log2 𝑛 with 𝑛2/3 gives the stated query condition. □ Per-color search trees are also used for DRM [SX20, proof of Theorem 2]. The data structure of Theorem 7.1 extends this approach to dynamic subtrees by ordering the color trees through a shared Euler sequence. Comparing two positions in that sequence takes O (log 𝑛) time instead of O (1) time for array positions, which accounts for the additional logarithmic factor.

8

Experimental Evaluation

8.1

Datasets and Methods

We used 5 real-world, publicly available datasets in our scalability experiments, as well as 2 sample datasets derived from them; see Table 1. Following [ZBT+ 26], we derived all datasets except Amazon [MTSvdH15] by constructing a generalized suffix tree for each original dataset (a string collection) and coloring each leaf with the id of the string in the collection, to derive large-scale datasets. Amazon is a tree dataset, representing a product taxonomy, whose product leaves are colored by sales-rank bands; see Appendix B.1 for details. In the FDSM experiments and Section 8.5, we used a dataset, called Files, which is derived from the LLVM directory hierarchy [LLV25]. The latter is a tree formed by directories and files in the source-code repository of an open-source compiler infrastructure project [LLV25]. We compare our DSM data structure to: (I) A baseline based on the reduction to Dynamic Range Mode (DRM) [EZHMS18], outlined in the introduction. Specifically, this baseline orders the leaves of T in the DFS order. This reduces a subtree-mode query to a range-mode query, and a leaf update to a point update query. This baseline uses our implementation of the state-of-the-art practical data structure for DRM [EZHMS18], which takes O (𝑛4/3 ) time to build, occupies O (𝑛) space, and answers queries and updates in O (𝑛2/3 ) time. The implementation defaults to a block size of ⌈𝑚 2/3 ⌉, where 𝑚 is the number of leaves of T . (II) SCM-rebuild, which builds from scratch the static SCM data structure [ZBT+ 26] after each update. This approach was chosen, as it significantly outperformed other baselines for SM [ZBT+ 26] 15

Table 1: (a) Characteristics of the datasets used in the scalability experiments. (b) Files dataset used in the FDSM experiments and case study. (a) String-derived instances and Amazon.

Domain

News [ZCG16] WebKB [CDF+ 98] Genes [Kan13] Vir [Nat25] Amazon [MTSvdH15]

News 728 307 478 100 59 4 781 Web 35 429 531 26 068 175 167 790 340 Biology 519 275 197 499 580 789 569 887 249 Biology 287 825 267 249 925 868 1 466 143 588 E-commerce 863 317 859 478 9 3 802

𝑛

Genes-sam [Kan13] Biology + WebKB-sam [CDF 98] Web

3 723 300 4 693 596

# Leaves

|Δ|

Dataset

2 000 000 3 103 000

ℎ

76 10 000 101 31 030

(b) Files dataset derived from the LLVM Project repository.

Source

Snapshot

LLVM Project 10 Nov. 2025

# Directories # Files 15 637

𝑛

# Leaves ℎ |Δ|

166 441 182 079 166 442 16 399

which are omitted. Also, we omit a baseline that stores at every internal node the frequency of each color occurring below it and updates the counts at all ancestors of a changed leaf, due to its O (#leaves · ℎ) space and costly updates. For example, on a WebKB subtree with 𝑛 = 989 035, ℎ = 157, and |Δ| = 65 536, under 𝑄/𝑈 = 1/10, its updates were 4 and 40 times slower than DSM and FDSM, respectively, while its space was 90% larger than that of FDSM, and prohibitive for Vir.

8.2

Setup

To our knowledge, there are no publicly available query logs for SM. Thus, for our experiments (except the case studies), we generate synthetic workloads as follows. A query samples an internal node uniformly at random and returns the mode color in its subtree. An update samples a structural leaf (i.e., a node with no children in the tested tree) uniformly at random (with replacement) and replaces its current color 𝑐 with a color sampled uniformly from Δ \ {𝑐}; hence, no update leaves the color unchanged. We use workloads W𝑄/𝑈 with 𝑄/𝑈 ∈ {100, 50, 25, 5, 1, 1/100}, where 𝑈 and 𝑄 are the numbers of color updates and queries in each cycle, respectively. Each cycle performs 𝑈 color updates followed by 𝑄 SM queries. Let U and Q denote the total numbers of updates and queries in a complete workload, respectively. For the small datasets and Files, U + Q equals the number of structural leaves in the tested tree. At full scale, this gives 3 103 000, 478 100, 2 000 000, and 166 442 operations on WebKB-sam, News, Genes-sam, and Files, respectively. For the large datasets, the total operation count equals the number of structural leaves divided by 100 and rounded down, giving 260 681, 4 995 807, 2 499 258, and 8 594 operations on WebKB, Genes, Vir, and Amazon, respectively. When varying 𝛼, we also use a query-only workload WQ and an update-only workload WU . To examine the impact of 𝑛, we use nested instances 25%, 50%, 75%, and 100% of the nodes of the full tree. To examine the impact of |Δ|, we varied the color assignment of the full tree. We report average operation time (i.e., the average time over all the operations of a workload), construction time, and space (i.e., peak memory for construction and answering the workload). All experiments were conducted on compute nodes equipped with an AMD EPYC 7702 64-Core Processor (2.00 GHz), 1 TB of RAM, and Ubuntu 22.04.5 LTS. Our code and data can be found at https://github.com/JialongZhou666/dynamic-subtreemode.

16

Table 2: Comparison of the 𝛼 selection methods on different datasets and workloads W𝑄/𝑈 . The constants 𝐴, 𝐵 in the Analytic method are measured in nanoseconds (ns). The Exhaustive-search and Analytic method take the same time, measured in seconds. # Eval. denotes the number of evaluations performed. exhaust . The Error of every method is relative to 𝛼opt Exhaust.

Analytic

exhaust 𝛼opt

Exh. & Ana.

Brent’s Method

Newton’s Method

𝑨 (ns) 𝑩 (ns)

analytic 𝛼opt

Error (%)

Time (s)

Brent 𝛼opt

WebKB-sam 100 (𝑛 = 4.69 × 106 ) 1 1/100

0.4 0.5 0.5

2.054 2.292 2.350

0.865 0.880 0.879

0.322 0.469 0.618

19.5 6.2 23.6

77 760 56 820 16 620

0.369 0.500 0.562

7.7 0.0 12.4

8 11 8

37 747 106

0.355 0.575 0.564

11.2 15.0 12.8

15 12 9

69 1 694 94

News 100 (𝑛 = 7.28 × 105 ) 1 1/100

0.4 0.4 1.0

0.791 0.993 1.043

0.532 0.585 0.571

0.315 0.480 0.648

21.3 20.1 35.2

900 699 301

0.323 0.553 0.784

19.2 38.3 21.6

8 12 11

5 9 10

0.450 0.550 0.888

12.5 37.5 11.2

15 9 18

10 95 22

Genes-sam 100 (𝑛 = 3.72 × 106 ) 1 1/100

0.3 0.5 0.5

0.915 1.012 1.077

0.920 0.868 0.890

0.348 0.495 0.646

16.0 1.0 29.2

22 440 16 500 8 700

0.277 0.560 0.601

7.7 12.1 20.3

9 7 11

27 327 93

0.450 0.550 0.550

50.0 10.0 10.0

6 6 9

18 34 71

Dataset

8.3

𝑸/𝑼

Newton 𝛼opt

Error (%) # Eval. Time (s)

Error (%) # Eval. Time (s)

DSM Data Structure

8.3.1 Workload-aware Selection of 𝛼. Recall from Theorem 4.1 that 𝛼 ∈ [0, 1] affects both the SM query and update time. When a workload contains both SM queries and updates, 𝛼 controls the trade-off, and it is thus important to find a value 𝛼opt that minimizes time for answering the workload. In the following, we examine four different methods for finding this value. Analytic. For each dataset and workload W𝑄/𝑈 , we first evaluate 11 fixed values for 𝛼, namely {0.0, 0.1, . . . , 1.0}. Let 𝑓𝑄 = 𝑄/(𝑄 + 𝑈) and 𝑓𝑈 = 𝑈/(𝑄 + 𝑈) denote the fractions of queries and updates, respectively. Motivated by the theoretical trade-off, we model the average mixed-operation time as 𝑇 (𝛼) = 𝑓𝑄 𝐴𝑛 𝛼 + 𝑓𝑈 𝐵𝑛1− 𝛼 , (1) where 𝑛 is the number of nodes of T , and 𝐴, 𝐵 are implementation-dependent constants for query and update cost, respectively. We estimate 𝐴 and 𝐵 by least-squares fitting of Equation  to the 11 fixed values  (1)   analytic

for 𝛼. Minimizing Equation (1) w.r.t. 𝛼 yields the predictor 𝛼opt analytic

= clip [0,1]

1 2

1+

ln ( 𝑓𝑈 𝐵)/( 𝑓𝑄 𝐴) ln 𝑛

,

where clip [0,1] projects the value onto [0, 1]. 𝛼opt decreases when queries dominate and increases when updates dominate. It is an approximation used to test how well the model of Equation (1) predicts e(·) in the bounds and changes caused by the value 𝛼opt , as it ignores logarithmic factors suppressed by O of 𝛼 in the data structure configuration. Brent’s method. We use Brent’s derivative-free bounded minimization [Bre73] to select 𝛼 ∈ [0, 1] that minimizes the measured average operation time. For each dataset and 𝑄/𝑈 ratio, we generate a pilot workload and candidate values are evaluated on the same pilot workload, containing one operation per ten Brent is then used on the full workload. structural leaves. The selected value 𝛼opt Newton’s method. We also minimize the measured average operation time using Newton’s method [NW06, DS96], estimating its first and second derivatives by finite differences. The method uses the same pilot workload as Brent’s method. Starting from 𝛼0 = 0.5, we restrict each iterate to [0, 1] and terminate when Newton is used on the the improvement or step size is below 0.01, or after six iterations. The resulting 𝛼opt full workload. Exhaustive-search. For each dataset and workload W𝑄/𝑈 , we evaluate the DSM data structure at every candidate value 𝛼 ∈ {0.0, 0.1, . . . , 1.0} and record the average operation time. We then select the value exhaust that yields the minimum observed time, and compare it to the 𝛼 values selected by the other 𝛼opt methods. Comparison of the 𝛼 selection methods. Table 2 reports the fitted constants 𝐴, 𝐵, the analytic prediction analytic exhaust . Analytic models the trade-off in Theorem 4.1, achieving 𝛼opt , and the exhaustive-grid reference 𝛼opt 19.1% average relative error, but requires the same 11-point sweep as Exhaustive-search, costing up to 21.6 hours. Brent’s and Newton’s reduce calibration to 5–747 s and 10–1694 s, respectively. Brent’s achieves lower average (15.5% versus 18.9%) and maximum (38.3% versus 50.0%) errors, making it our 17

10

1

Query

10

−1

10

−3

Update

0.0

0.2

0.4

α

0.6

0.8

1.0

10

5

10

3

10

1

10

−1

10

−3

0.0

5

10

3

10

1

10 10

Update

0.2

0.4

α

0.6

0.8

1.0

10

5

10

3

10

1

Query

10

−1

10

−3

0.0

(b) WebKB

0.2

0.4

Update

α

0.6

0.8

Query

Update

−1

−3

0.0

0.2

0.4

α

0.6

0.8

1.0

10

3

10

2

10

1

10

0

10

−1

10

−2

10

−3

Query

0.0

(d) Vir

0.2

0.4

2500 Construction Peak memory

Update

α

0.6

1.0

(c) Genes 5000

Runtime (μs/op)

Runtime (μs/op)

(a) WebKB-sam 10

Query

0.8

4000

Peak memory (MiB)

10

3

Runtime (μs/op)

5

Runtime (ms)

10

Runtime (μs/op)

Runtime (μs/op)

default heuristic. These errors measure agreement with the best tested grid value of 𝛼, rather than runtime optimality.

2000

3000

1500

2000

1000

1000 0

1.0

(e) Amazon

500 0.0

0.2

0.4

α

0.6

0.8

1.0

0

(f) WebKB-sam

10 10

50

25

5

3

1

−1

0.0

0.2

0.4

α

0.6

0.8

1.0

10

4

10

3

10

2

10

1

10

0

100

10

2

10

1

10

0

10

100

50

25

5

TO

0.0

0.2

0.4

α

0.6

0.8

1.0

5

DSM

1250

−1

0.2

0.4

α

0.6

(d) Amazon

5

10

4

10

3

10

2

10

1

10

0

100

0.0

1000 750 500

0.8

1.0

0

0.0

0.2

0.4

α

0.6

0.2

0.4

50

α

TO

25

5

0.6

0.8

1.0

0.8

1.0

(c) Vir

250 0.0

10

(b) Genes Runtime (ms)

Runtime (µs/op)

3

25

TO: 25, 5

(a) WebKB 10

50

Runtime (µs/op)

10

100

5

Peak memory (MiB)

10

Runtime (µs/op)

Runtime (µs/op)

Figure 3: Impact of 𝛼: (a)–(e) average operation time for WQ and WU ; (f) construction time and space on WebKB-sam. Crosses denote 24-hour time-outs.

0.8

(e) Construction time

1.0

DSM

400 300 200 100 0

0.0

0.2

0.4

α

0.6

(f) Space

Figure 4: Impact of 𝛼: (a)–(d) average operation runtime for W100 , W50 , W25 , and W5 ; (e)–(f) construction runtime and space on Amazon. TO denotes a 24-hour time-out. 8.3.2 Impact of 𝛼. Figures 3(a)–(e) show the impact of 𝛼 on average query time and update time in the query-only workload WQ and the update-only workload WU . The query time increases with 𝛼 in e(𝑛 𝛼 ) bound of Theorem 4.1, whereas the update time decreases with 𝛼 in line with the line with the O 1− 𝛼 e(𝑛 O ) bound of Theorem 4.1. Figure 3(f) shows that 𝛼 has a small impact on construction time and space on WebKB-sam, as expected by Theorem 4.1. Figures 4(a)–(d) show the impact of 𝛼 on average operation time (over all query and update operations) under different workloads: W100 , W50 , W25 , and W5 . The value of 𝛼 that minimizes the average operation time is 𝛼 = 0.2 on Amazon and 0.4 on all other datasets. Figures 4(e) and 4(f) show the impact of 𝛼 on construction time and space. Again, the impact of 𝛼 is very small, in line with Theorem 4.1. Results for News and Genes-sam are in Appendix B.2. 8.3.3 Impact of 𝑛. We show that DSM is up to 4 orders of magnitude faster than the competitors and substantially faster to construct on large datasets. Its space grows linearly with 𝑛 and is about 3 times larger than DRM. Thus, DSM offers an attractive time/space trade-off. Appendixes B.2 and B.3 contain additional results. 18

n

2.18M

10

10

2

10

1

10

0

8.86M

17.71M

n

−1

8.86M

DRM

26.57M

35.43M

10

5

10

4

10

3

10

2

10

1

6

10

5

10

4

n

(m) Genes

0

−1

DSM

10

4

10

3

10

2

10

1

DRM

217.86K 433.14K 648.26K 863.32K

(n) Amazon

4

10

3

10

2

10

1

10

0

10

126.27M 254.97M 385.99M 519.28M

10

4

10

3

DSM

10

2

10

1

64.49M

DSM

DRM

10

135.50M 209.77M 287.83M

2

10

1

10

1

10

0

SCM-rebuild

1.05M

n

2.18M

4.69M

(o) WebKB-sam

5

10

4

10

3

10

2

DSM

8.86M

2

10

1

10

0

17.71M

n

DRM

DSM

217.86K 433.14K 648.26K 863.32K

n

(e) Amazon

DRM

DSM

10

10

35.43M

(p) WebKB

10

2

10

1

10

0

DRM

SCM-rebuild

TO

2

818.60K

1.05M

n

2.18M

6

10

5

10

4

10

3

DSM

10

6

10

5

10

4

10

3

126.27M 254.97M 385.99M 519.28M

(q) Genes

TO

TO

TO

TO

1.05M

2.18M

4.69M

n

DSM

DRM

17.71M

26.57M

n

35.43M

(l) WebKB

DRM

n

SCM-rebuild

818.60K

8.86M

4.69M

(k) WebKB-sam 10

DRM

(f) WebKB-sam

3

DRM

26.57M

DSM

−1

n

217.86K 433.14K 648.26K 863.32K

10

3

10

10

135.50M 209.77M 287.83M

DSM

2

10

TO

(j) Amazon

TO 818.60K

TO

n

3

10

TO

64.49M

n

DRM

DRM

(d) Vir

(i) Vir 10

DSM

−1

(c) Genes

DRM

n

5

10

n

TO

DSM

10

Runtime (µs/op)

1

10

DRM

Runtime (μs/op)

10

DSM

Runtime (μs/op)

2

10

35.43M

(h) Genes

DRM

126.27M 254.97M 385.99M 519.28M

26.57M

n

Runtime (ms)

Runtime (ms)

DSM 7

10

n

126.27M 254.97M 385.99M 519.28M

(g) WebKB 10

17.71M

3

10

(b) WebKB Runtime (μs/op)

Runtime (μs/op)

DSM

3

0

4.69M

(a) WebKB-sam 10

1

10

10

Runtime (ms)

1.05M

10

DRM

DSM

Peak memory (MiB)

818.60K

2

Runtime (ms)

−1

3

10

Peak memory (MiB)

TO

10

Runtime (μs/op)

10

DSM

SCM-rebuild

Peak memory (MiB)

1

DRM

Runtime (μs/op)

10

DSM

Runtime (μs/op)

3

Peak memory (MiB)

5

10

Runtime (μs/op)

Runtime (µs/op)

10

10

3

10

2

10

1

DRM

217.86K 433.14K 648.26K 863.32K

n

(r) Amazon

Figure 5: Impact of 𝑛. (a)–(e) report average operation time on W100 and (f)–(j) on W1/100 . (k)–(n) report construction time and (o)–(r) construction space on W100 . TO indicates a 24-hour run time-out. Figures 5(a)–(e) show that our approach is up to four orders of magnitude faster than both SCMrebuild and DRM under the query-heavy workload W100 . Even on the smaller WebKB-sam dataset (see Figure 5(a)), SCM-rebuild is impractical, requiring more than 24 hours for 𝑛 ≥ 4.69 · 106 . This motivates the need for dynamic data structures for Subtree Mode. Figures 5(a)–(e) also show the significant benefit of our data structure that exploits the tree structure of the DSM problem over solutions via the more general DRM problem. Specifically, DSM is up to four orders of magnitude faster than DRM. The increasing operation times with 𝑛 for DSM are consistent with Equation (1). Figures 5(f)–(j) show that our approach is up to 185 times faster than DRM, even when updates dominate, as in W1/100 . It is faster on the larger Genes and Vir datasets; by up to 70% faster on Amazon and up to 185 times on Genes. On the other hand, SCM-rebuild is again impractical, even on the smaller WebKB-sam dataset, where it timed-out after 24 hours (see Figure 5(f)). Figures 5(k)–(n) show the impact of 𝑛 on construction time under W100 (the results for W1/100 are analogous; see Appendix B.3). On the small WebKB-sam dataset, DSM is on average about two times faster to construct than SCM-rebuild. On the large WebKB and Genes datasets, DSM outperforms DRM by 4.3 and 5.6 times on average, respectively. Importantly, the advantage of DSM over DRM increases with 𝑛. These results are consistent with the construction-time bounds of O (𝑛) for DSM and O (𝑛4/3 ) for DRM. SCM-rebuild did not terminate within 24 hours in the large datasets. Figures 5(o)–(q) show the impact of 𝑛 on space under W100 (the results for W1/100 are analogous; see Appendix B.3). As expected, the space of all approaches scales linearly with 𝑛. On the small WebKB-sam dataset, DRM and SCM-rebuild use on average 66% and 45% less space than DSM, respectively. On the large datasets, DSM uses a reasonable amount of space, which is approximately three times more than that of DRM. 8.3.4 Impact of |Δ|. DSM is often orders of magnitude faster than both competitors and substantially faster to construct on large datasets. Its space is insensitive to |Δ|, as expected, but it is more than the competitors. Thus, our approach offers a desirable time/space trade-off. Additional results are in Appendixes B.2 and B.4. Figures 6(a)–(e) show that DSM is substantially faster than both competitors under the query-heavy workload W100 and Figures 6(f)–(j) that it remains faster than DRM under W1/100 (e.g., by up to 25.4 times on the string-derived datasets and up to 80% on Amazon). On the small WebKB-sam dataset, DSM is on average more than four orders of magnitude faster than SCM-rebuild and 4.7 times faster than DRM. On WebKB and Amazon, DSM is up to 600 times faster than DRM. On the largest Genes and

19

6K

12K

10

10

(b) WebKB

DRM

3

Runtime (μs/op)

Runtime (μs/op)

DSM

10

2

1

6K

12K

|Δ|

15K

30K

10

4

10

3

10

2

10

1

10

10

DRM

6

5

TO

TO

TO

TO

111K

222K

444K

887K

|Δ|

(m) Genes

DRM

10

10

10

4

10

3

10

2

TO

222K

|Δ|

444K

10

887K

DRM

3

2

478

884

3.8K

|Δ|

TO

TO

111K

222K

444K

887K

|Δ|

10

0

7.3K

DSM

72K

32K

(n) Amazon

10

10

2

10

1

|Δ|

108K

10

2

10

1

10

144K

DRM

12K

TO

36K

72K

108K

144K

SCM-rebuild

15K

|Δ|

10

10

30K

|Δ|

(o) WebKB-sam

3

10

2

10

1

10

0

10

DSM

DRM

−1

478

884

3.8K

7.3K

|Δ|

32K

DRM

10

3

10

2

DSM

DRM

10

6

10

4

10

2

10

0

884

3.8K

|Δ|

7.3K

32K

6K

12K

DRM

TO

6K

SCM-rebuild

TO

TO

12K

15K

30K

(f) WebKB-sam

SCM-rebuild

0

478

DSM

|Δ|

(e) Amazon

15K

30K

10

6

10

5

10

4

DSM

6K

12K

|Δ|

(j) Amazon 10

6K

TO

DSM

3

DSM

TO

DRM

1

36K

TO

(d) Vir

(i) Vir

4

DSM

TO

(c) Genes

(h) Genes Runtime (ms)

Runtime (ms)

10

DSM

111K

(g) WebKB DSM

10

30K

Runtime (μs/op)

(a) WebKB-sam

15K

|Δ|

|Δ|

TO

0

1

10

Runtime (µs/op)

10

0

10

DRM

Runtime (μs/op)

1

DSM

Runtime (μs/op)

2

10

10

DRM

Runtime (ms)

30K

10

DSM

1

(k) WebKB-sam

|Δ|

DRM

15K

30K

(l) WebKB

5

DSM

DRM

DSM

4

3

6K

12K

|Δ|

15K

30K

(p) WebKB

10

10

DRM

DSM

Peak memory (MiB)

15K

3

DRM

Runtime (ms)

12K

10

DSM

Peak memory (MiB)

6K

4

Runtime (μs/op)

−1

5

10

Runtime (μs/op)

1

10

Peak memory (MiB)

10

SCM-rebuild

3

Peak memory (MiB)

10

DRM

Runtime (μs/op)

Runtime (µs/op)

DSM

10

6

5

TO

TO

TO

TO

111K

222K

444K

887K

|Δ|

(q) Genes

10

3

10

2

10

1

478

884

3.8K

|Δ|

DRM

7.3K

32K

(r) Amazon

Figure 6: Impact of |Δ|. (a)–(e) report average operation time on W100 and (f)–(j) on W1/100 . (k)–(n) report construction time and (o)–(r) construction space on W100 . TO indicates a 24-hour run time-out. Vir datasets, DRM does not terminate within 24 hours for any |Δ|. Figures 6(k)–(n) show the impact of |Δ| on construction time under W100 . On the small WebKB-sam dataset, DSM is 64% faster on average to construct than SCM-rebuild but it is 2 times slower on average than DRM (and 31% slower than DRM on Amazon). On the larger datasets, however, DSM significantly outperforms DRM; it was 2 times faster on average on WebKB, while DRM did not terminate within 24 hours in Genes. These results are in line with the construction time bounds, O (𝑛) for DSM vs. O (𝑛4/3 ) for DRM. Figures 6(o)–(q) show the impact of |Δ| on space under W100 , which is small as expected by the space complexities of the approaches. On WebKB-sam, DRM and SCM-rebuild use on average 64.5% and 46.2% less space than DSM, respectively. On WebKB, DSM uses about three times more space than that of DRM.

8.4

FDSM Data Structure

We report results for Files; additional results are in Appendix B.5. 8.4.1 SM Queries and Updates. We evaluate FDSM under the workload W100 , which only has subtree mode queries and updates. This is to compare it against DSM and DRM, which do not support add/delete leaf and link-cut update operations, in addition to SCM-rebuild. For the experiments using Files, we assign colors to tree leaves so that each color occurs approximately equally often in the leaves. Starting with |Δ| = 100, we merge colors to obtain |Δ| ∈ {5, 10, 25, 50, 100} and use these values in the experiments varying Δ. In the experiments varying 𝑛, we use |Δ| = 50. Impact of 𝑛. Figure 7(a) shows that FDSM is more than 4 times (respectively, over two orders of magnitude) faster than DRM (respectively, SCM-rebuild) on average under W100 . The operation time of FDSM increases only slightly with 𝑛, consistent with the theoretical bounds of Theorem 7.1. DSM is approximately 5 times faster than FDSM, as it is specifically designed for only query and update operations (unlike FDSM). Figure 7(b) shows the impact of 𝑛 on construction time under W100 . Our FDSM data structure is on average about two times faster to construct than DSM and more than four times faster than SCM-rebuild. However, DRM is about 1.4 times faster to construct than FDSM on average. The construction time of all methods increases in line with their respective bounds. Figure 7(c) shows the impact of 𝑛 on space under W100 . Interestingly, FDSM uses 52% less space than DSM on average and 9% less space than SCM-rebuild. On the other hand, DRM uses 43% less 20

space on average than FDSM. As expected, the space of all approaches scales linearly with 𝑛. Impact of |Δ|. Figure 8(a) shows that FDSM is over two orders of magnitude (respectively, more than 3 times) faster than SCM-rebuild (respectively, DRM) on average under W100 . The average operation time of FDSM increases by only 54% as |Δ| increases 20 times, showing a much weaker dependence on |Δ| than the linear dependence in its worst-case query-time bound of O (|Δ| log2 𝑛) in Theorem 7.1. DSM is about 5 times faster than FDSM, as it is designed for query and update operations on a fixed tree. Figure 8(b) shows that FDSM is more than 4 (respectively, 2) times faster to construct than SCMrebuild (respectively, DSM) on average under W100 . DRM takes on average 21% less time to be constructed than FDSM. Importantly, the construction time of FDSM varies by less than 3% as |Δ| increases 20 times, consistent with its O (𝑛 log 𝑛) construction-time bound. Figure 8(c) shows that FDSM uses on average 21% (respectively, 52%) less space than SCM-rebuild (respectively, DSM) under W100 . DRM uses on average 40% less space than FDSM. Importantly, the space consumption of FDSM varies by less than 0.3% as |Δ| increases 20 times, consistent with its O (𝑛) space bound.

4

10

3

10

2

10

1

10

0

10

FDSM DSM

DRM SCM-rebuild

−1

45,521

91,040

n

136,559

182,079

(a) Avg. operation time

10

3

10

2

10

1

10

0

FDSM DSM

DRM SCM-rebuild

Peak memory (MiB)

10

Runtime (ms)

Runtime (μs/op)

8.4.2 Leaf additions and deletions. We evaluate FDSM using workloads consisting of leaf additions and deletions, in which a new colored leaf is added and then immediately deleted.

45,521

91,040

n

136,559

182,079

10

3

10

2

10

1

10

0

FDSM DSM

45,521

(b) Construction time

91,040

DRM SCM-rebuild

n

136,559

182,079

(c) Space

4

10

3

10

2

10

1

10

0

10

FDSM DSM

DRM SCM-rebuild

−1

5

10

25

|Δ|

50

100

(a) Avg. operation time

10

3

10

2

10

1

10

0

FDSM DSM

DRM SCM-rebuild

Peak memory (MiB)

10

Runtime (ms)

Runtime (μs/op)

Figure 7: Impact of 𝑛 on Files for W100 .

5

10

25

|Δ|

50

100

10

3

10

2

10

1

FDSM DSM

5

(b) Construction time

10

DRM SCM-rebuild

25

50

|Δ|

100

(c) Space

Figure 8: Impact of |Δ| on Files for W100 . 20

4

10

5

0

0

91,040

n

136,559

182,079

(a) Avg. operation time Add

4

n

136,559

0

0

25

50

100

(d) Avg. operation time

10

45,520

91,040

n

136,559

182,079

(c) Space 40

10

5

|Δ|

20

0

182,079

15

2

10

91,040

20

6

5

45,520

30

(b) Construction time

Remove

Runtime (ms)

8

Runtime (μs/op)

15

2

45,520

40

Peak memory (MiB)

6

Runtime (ms)

Runtime (μs/op)

Remove

Peak memory (MiB)

Add

8

5

10

25

|Δ|

50

100

(e) Construction time

30

20

10

0

5

10

25

|Δ|

50

100

(f) Space

Figure 9: Impact of 𝑛 and |Δ| on FDSM leaf insertions and deletions: (a)–(c) varying 𝑛 with |Δ| = 50; (d)–(f) varying |Δ| with 𝑛 = 182079. Impact of 𝑛. We use 4 nested instances of the Files dataset with |Δ| = 50, replaying the same sequence of 83 221 leaf addition/deletion pairs at every size. Attachment points are sampled uniformly from the 21

20

40

Peak memory (MiB)

Runtime (ms)

Runtime (μs/op)

20 40

15

10

5

0

45,521

91,040

n

136,559

0

182,079

(a) Move time

45,521

91,040

n

136,559

|Δ|

50

(d) Move time

100

10

0

91,040

n

136,559

182,079

40

15

5

25

45,521

(c) Space Peak memory (MiB)

Runtime (ms)

Runtime (μs/op)

10

10

10

(b) Construction time

20

5

20

0

182,079

20

0

30

5

10

25

|Δ|

50

100

(e) Construction time

30

20

10

0

5

10

25

|Δ|

50

100

(f) Space

Figure 10: Impact of 𝑛 and |Δ| on FDSM subtree moves: (a)–(c) varying 𝑛 with |Δ| = 50; (d)–(f) varying |Δ| with 𝑛 = 182079. original nodes of the smallest instance, which are also present in every larger instance. The attachment nodes, insertion colors, operation order, and workload length are fixed across sizes. Figure 9(a) shows that the average time of leaf additions (respectively, deletions) increases by only about 69% (respectively, 62%) as 𝑛 increases 4 times. Leaf additions take approximately 1.7 times longer than deletions on average. Figure 9(b) shows that the construction time of FDSM increases by approximately 3.7 times as 𝑛 increases 4 times. Figure 9(c) shows that the space consumption of FDSM increases overall by approximately 2 times as 𝑛 increases 4 times. These results are consistent with the bounds in Theorem 7.1. Impact of |Δ|. We use the Files dataset and perform 83 221 leaf addition/deletion pairs per color setting. Attachment points alternate between randomly selected initial leaves and internal nodes. Figure 9(d) shows that the average time of leaf additions (respectively, deletions) increases by only 24% (respectively, 37%) as |Δ| increases 20 times. Figure 9(e) shows that the construction time of FDSM increases by only 1.3% as |Δ| increases 20 times. Figure 9(f) shows that the space consumption of FDSM varies by less than 0.2% as |Δ| increases 20 times. These results are consistent with the bounds in Theorem 7.1. 8.4.3 Link-Cut Updates (Subtree Moves). We evaluate FDSM using workloads comprised of link-cut updates (subtree moves), generated randomly while preserving the validity of the evolving tree. Impact of 𝑛. We use 4 nested trees with |Δ| = 50, performing the same sequence of 166 442 subtree moves at every size, with node IDs remapped appropriately. Each move detaches a non-root subtree and reattaches it under another node outside that subtree. The moves are generated randomly on the evolving tree, ensuring that every operation is valid. Figure 10(a) shows that the average operation time increases as 𝑛 increases, as expected by the respective bound. Figure 10(b) shows that the construction time increases by approximately 3.7 times as 𝑛 increases 4 times, consistent with the worst-case O (𝑛 log 𝑛) bound. Figure 10(c) shows that the space for FDSM increases in line with the O (𝑛) space bound in Theorem 7.1. Impact of |Δ|. We use the Files dataset and a workload comprised of 166 442 subtree moves. Figure 10(d) shows that the average time of subtree moves increases by only about 58% as |Δ| increases 20 times, so |Δ| has a smaller impact than that implied by the O (|Δ| log2 𝑛) bound in Theorem 7.1. Figure 10(e) shows that the construction time of FDSM varies by less than 2.1% as |Δ| increases 20 times, consistent with its O (𝑛 log 𝑛) construction-time bound. Figure 10(f) shows that the space of FDSM varies by less than 0.2% as |Δ| increases 20 times, consistent with its O (𝑛) space bound.

22

10

0

(a) Workload

10

1

10

0

10

−1

Query Update

(b) Operations

10

3

10

2

10

1

(c) Workload

60 40 20 0

Query Add Delete Move

1

10

2

80

Runtime (μs/op)

10

3

4

SCM-rebuild

2

10

10

FDSM

10

10

4

Runtime (ms)

10

3

5

DSM DRM

4

10

DSM DRM

10

Runtime (μs/op)

10

5

DSM

6

DRM

Runtime (ms)

10

(d) Operations

Figure 11: (a) Total query and update time and (b) average query and update time for DSM and DRM on Amazon; (c) total workload time and (d) average operation time on Files. Error bars denote standard deviations over five repetitions.

8.5

Case Studies

We evaluate our data structures using real changes in an e-commerce platform and a software repository. We replay these changes in their original order, together with subtree-mode queries. The construction time and space results are omitted for space reasons. E-Commerce Product Taxonomy. We use the Amazon dataset to evaluate whether DSM maintains meaningful category summaries under real rating updates. Unlike the scalability experiments, we assign products to five rating tiers derived from their cumulative average ratings and replay subsequent reviews chronologically. The replay contains 1 000 tier-changing updates and 5 845 queries to the affected categories and their ancestors, up to the root. Figure 11(a) shows that DSM executes the queries and updates about 71 000 times faster than DRM. Figure 11(b) shows that queries and updates take only about 0.34 and 0.87 microseconds on average, respectively. The mode or its frequency changes more than 3 000 times during the replay, demonstrating the importance of efficiently maintaining subtree-mode information as the data evolve. An Evolving Software Repository. We use the Files dataset to evaluate whether FDSM efficiently maintains directory summaries as a real software repository evolves. We construct the initial tree from the LLVM repository snapshot of 10 November 2025, representing directories as internal nodes and files as leaves, with edges following the directory hierarchy. Unlike the scalability experiments, we color each file leaf by one of 14 extension-based categories, including source files, headers, LLVM intermediate representations, documentation, and scripts. Files without extensions form a separate category, while unclassified extensions are grouped as “other”. The same category mapping is used throughout the replay. Starting from this snapshot, we replay 1 000 consecutive LLVM commits: file and directory additions and deletions are replayed as structural updates, and cross-directory moves as link-cut updates; after each commit, we query affected directories, their ancestors, five fixed major project directories, and the repository root. The workload contains 13 501 operations, including 12 806 queries and 695 updates. Figure 11(c) shows that FDSM processes the entire workload about 80 times faster than SCM-rebuild. Figure 11(d) shows that queries, leaf additions, and deletions take only about 3, 10, and 10 microseconds on average, respectively, while subtree moves take about 46 microseconds. The mode or its frequency changes more than 1 000 times across 194 directories, demonstrating the importance of solving SM in the dynamic setting.

9

Conclusion

Our work initiated the study of dynamic subtree mode, proposing efficient data structures for DSM and FDSM with conditionally near-optimal bounds. It also raises a few direct open questions. First, our conditional optimality for DSM and hardness results for FDSM motivate studying approximate FDSM,

23

which reports a sufficiently frequent color instead of an exact subtree mode. Other directions include incremental FDSM, allowing only node additions for append-only applications, and reporting the top-𝐾 most frequent colors in a subtree.

AI Usage Declaration The authors used Anthropic’s Claude Opus 5.5 via the chat interface. The core ideas, algorithms, and proofs presented in this paper were developed entirely by the authors. The authors wrote the initial implementation and subsequently used the model to assist with code optimization. The authors also wrote the initial manuscript and subsequently used the model to help identify imprecise statements and minor errors, and to improve clarity and presentation. The model also wrote the TikZ code for Figures 1 and 2 based on the authors’ description. The authors reviewed all AI-assisted revisions and take full responsibility for the final content of the paper and the accompanying code.

References [ABV18]

Amir Abboud, Arturs Backurs, and Virginia Vassilevska Williams. If the current clique algorithms are optimal, so is Valiant’s parser. SIAM Journal on Computing, 47(6):2527– 2555, 2018. doi:10.1137/16M1061771.

[AHdLT05]

Stephen Alstrup, Jacob Holm, Kristian de Lichtenberg, and Mikkel Thorup. Maintaining information in fully dynamic trees with top trees. ACM Transactions on Algorithms, 1(2):243–264, 2005. doi:10.1145/1103963.1103966.

[ASJ+ 17]

N. Arora, V. J. Schuenemann, G. Jäger, et al. Origin of modern syphilis and emergence of a pandemic Treponema pallidum cluster. Nature Microbiology, 2:16245, 2017. doi: 10.1038/nmicrobiol.2016.245.

[BFC00]

Michael A. Bender and Martín Farach-Colton. The LCA problem revisited. In Proceedings of the 4th Latin American Symposium on Theoretical Informatics (LATIN 2000), pages 88–94. Springer, 2000. doi:10.1007/10719839_9.

[BFF+ 15]

Robert Brunel, Jan Finis, Gerald Franz, Norman May, Alfons Kemper, Thomas Neumann, and Franz Färber. Supporting hierarchical data in SAP HANA. In Proceedings of the 31st IEEE International Conference on Data Engineering (ICDE 2015), pages 1280–1291. IEEE, 2015. doi:10.1109/ICDE.2015.7113376.

[BKMT05]

Prosenjit Bose, Evangelos Kranakis, Pat Morin, and Yihui Tang. Approximate range mode and range median queries. In Proceedings of the 22nd Annual Symposium on Theoretical Aspects of Computer Science (STACS 2005), pages 377–388. Springer, 2005. doi:10.1007/978-3-540-31856-9_31.

[BMK16]

Robert Brunel, Norman May, and Alfons Kemper. Index-assisted hierarchical computations in main-memory RDBMS. Proceedings of the VLDB Endowment, 9(12):1065–1076, 2016. doi:10.14778/2994509.2994524.

[Bre73]

Richard P. Brent. Algorithms for Minimization Without Derivatives. Prentice-Hall, 1973.

[CDF+ 98]

Mark Craven, Dan DiPasquo, Dayne Freitag, Andrew McCallum, Tom Mitchell, Kamal Nigam, and Seán Slattery. Learning to extract symbolic knowledge from the world wide web. In Proceedings of the Fifteenth National Conference on Artificial Intelligence (AAAI 1998), pages 509–516. AAAI Press, 1998. URL: https://www.aaai.org/Library/ AAAI/1998/aaai98-072.php.

24

[CDL+ 14]

Timothy M. Chan, Stephane Durocher, Kasper Green Larsen, Jason Morrison, and Bryan T. Wilkinson. Linear-space data structures for range mode query in arrays. Theory of Computing Systems, 55(4):719–741, 2014. doi:10.1007/s00224-013-9455-2.

[CLRS22]

Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms. MIT Press, 4th edition, 2022.

[DS96]

John E. Dennis, Jr. and Robert B. Schnabel. Numerical Methods for Unconstrained Optimization and Nonlinear Equations. SIAM, 1996.

[DSR92]

Luc Devroye, Wojciech Szpankowski, and Bonita Rais. A note on the height of suffix trees. SIAM Journal on Computing, 21(1):48–53, 1992. doi:10.1137/0221005.

[DSST16]

Stephane Durocher, Rahul Shah, Matthew Skala, and Sharma V. Thankachan. Linearspace data structures for range frequency queries on arrays and trees. Algorithmica, 74(1):344–366, 2016. doi:10.1007/s00453-014-9947-8.

[EZHMS18] Hicham El-Zein, Meng He, J. Ian Munro, and Bryce Sandlund. Improved time and space bounds for dynamic range mode. In Proceedings of the 26th Annual European Symposium on Algorithms (ESA 2018), pages 25:1–25:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2018. doi:10.4230/LIPIcs.ESA.2018.25. [FBK+ 15]

Jan Finis, Robert Brunel, Alfons Kemper, Thomas Neumann, Norman May, and Franz Färber. Indexing highly dynamic hierarchical data. Proceedings of the VLDB Endowment, 8(10):986–997, 2015. doi:10.14778/2794367.2794369.

[FL06]

Vince Fuller and Tony Li. Classless inter-domain routing (CIDR): The internet address assignment and aggregation plan. RFC 4632, Internet Engineering Task Force, 2006. doi:10.17487/RFC4632.

[FM14]

Arash Farzan and J. Ian Munro. A uniform paradigm to succinctly encode various families of trees. Algorithmica, 68(1):16–40, 2014. doi:10.1007/s00453-012-9664-0.

[GCB+ 97]

Jim Gray, Surajit Chaudhuri, Adam Bosworth, Andrew Layman, Don Reichart, Murali Venkatrao, Frank Pellow, and Hamid Pirahesh. Data cube: A relational aggregation operator generalizing group-by, cross-tab, and sub-totals. Data Mining and Knowledge Discovery, 1(1):29–53, 1997. doi:10.1023/A:1009726021843.

[GH22]

Younan Gao and Meng He. Faster path queries in colored trees via sparse matrix multiplication and min-plus product. In Proceedings of the 30th Annual European Symposium on Algorithms (ESA 2022), pages 59:1–59:15. Schloss Dagstuhl – LeibnizZentrum für Informatik, 2022. doi:10.4230/LIPIcs.ESA.2022.59.

[GJLT10]

Mark Greve, Allan Grønlund Jørgensen, Kasper Dalgaard Larsen, and Jakob Truelsen. Cell probe lower bounds and approximations for range mode. In Proceedings of the 37th International Colloquium on Automata, Languages and Programming (ICALP 2010), pages 605–616. Springer, 2010. doi:10.1007/978-3-642-14165-2_51.

[GPVX21]

Yuzhou Gu, Adam Polak, Virginia Vassilevska Williams, and Yinzhan Xu. Faster monotone min-plus product, range mode, and single source replacement paths. In Proceedings of the 48th International Colloquium on Automata, Languages, and Programming (ICALP 2021), pages 75:1–75:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.ICALP.2021.75.

[HK99]

Monika Rauch Henzinger and Valerie King. Randomized fully dynamic graph algorithms with polylogarithmic time per operation. Journal of the ACM, 46(4):502–516, 1999. doi:10.1145/320211.320215. 25

[HKNS15]

Monika Henzinger, Sebastian Krinninger, Danupon Nanongkai, and Thatchaphol Saranurak. Unifying and strengthening hardness for dynamic problems via the online matrix-vector multiplication conjecture. In Proceedings of the 47th Annual ACM Symposium on Theory of Computing (STOC 2015), pages 21–30. ACM, 2015. doi:10.1145/2746539.2746609.

[HKP11]

Jiawei Han, Micheline Kamber, and Jian Pei. Data Mining: Concepts and Techniques. Morgan Kaufmann, 3rd edition, 2011.

[HL23]

Meng He and Zhen Liu. Exact and approximate range mode query data structures in practice. In Proceedings of the 21st International Symposium on Experimental Algorithms (SEA 2023), pages 19:1–19:22. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2023. doi:10.4230/LIPIcs.SEA.2023.19.

[JX22]

Ce Jin and Yinzhan Xu. Tight dynamic problem lower bounds from generalized BMM and OMv. In Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing (STOC 2022), pages 1515–1528. ACM, 2022. doi:10.1145/3519935.3520036.

[Kan13]

Jonathan Kans. Entrez direct: E-utilities on the Unix command line. In Entrez Programming Utilities Help. National Center for Biotechnology Information, 2013. Accessed September 3, 2025. URL: https://www.ncbi.nlm.nih.gov/books/NBK179288/.

[KF16]

Thomas Krenc and Anja Feldmann. BGP prefix delegations: A deep dive. In Proceedings of the 2016 Internet Measurement Conference (IMC 2016), pages 469–475. ACM, 2016. URL: https://dl.acm.org/citation.cfm?id=2987458.

[KMS05]

Danny Krizanc, Pat Morin, and Michiel H. M. Smid. Range mode and range median queries on lists and trees. Nordic Journal of Computing, 12(1):1–17, 2005. URL: https://dl.acm.org/doi/10.5555/1195881.1195882.

[KYA+ 23]

Thomas Koch, Shuyue Yu, Sharad Agarwal, Ryan Beckett, and Ethan Katz-Bassett. PAINTER: Ingress traffic engineering and routing for enterprise cloud networks. In Proceedings of the 2023 ACM SIGCOMM Conference (SIGCOMM 2023), pages 360–377. ACM, 2023. doi:10.1145/3603269.3604868.

[LDD18a]

Yiu-Chang Lin, Pradipto Das, and Ankur Datta. Overview of the SIGIR 2018 ecom rakuten data challenge. In Proceedings of the SIGIR 2018 Workshop on eCommerce (eCom@SIGIR 2018). CEUR-WS.org, 2018. URL: https://ceur-ws.org/Vol-2319/ ecom18DC_paper_13.pdf.

[LDD18b]

Yiu-Chang Lin, Ankur Datta, and Giuseppe Di Fabbrizio. E-commerce product query classification using implicit user’s feedback from clicks. In Proceedings of the 2018 IEEE International Conference on Big Data (BigData 2018), pages 1955–1959. IEEE, 2018. doi:10.1109/BigData.2018.8622008.

[LKKN15]

Viktor Leis, Kan Kundhikanjana, Alfons Kemper, and Thomas Neumann. Efficient processing of window functions in analytical SQL queries. Proceedings of the VLDB Endowment, 8(10):1058–1069, 2015. doi:10.14778/2794367.2794375.

[LLV25]

LLVM Project. LLVM project source code repository. https://github.com/llvm/ llvm-project, 2025. Snapshot of November 10, 2025.

[LT23]

Kenneth C. Laudon and Carol Guercio Traver. E-Commerce 2023–2024: Business, Technology, Society. Pearson, 2023.

[MR06]

Peter Morville and Louis Rosenfeld. Information Architecture for the World Wide Web: Designing Large-Scale Web Sites. O’Reilly Media, 3rd edition, 2006. 26

[MTSvdH15] Julian McAuley, Christopher Targett, Qinfeng Shi, and Anton van den Hengel. Image-based recommendations on styles and substitutes. In Proceedings of the 38th International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR 2015), pages 43–52. ACM, 2015. doi:10.1145/2766462.2767755. [Mut02]

S. Muthukrishnan. Efficient algorithms for document retrieval problems. In Proceedings of the 13th Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2002), pages 657–666. SIAM, 2002. URL: https://dl.acm.org/doi/10.5555/545381.545469.

[Nat25]

National Center for Biotechnology Information. NCBI genome datasets. https://www. ncbi.nlm.nih.gov/datasets/genome/, 2025. Accessed October 13, 2025.

[NN17]

Gonzalo Navarro and Yakov Nekrich. Time-optimal top-𝑘 document retrieval. SIAM Journal on Computing, 46(1):80–113, 2017. doi:10.1137/140998949.

[NW06]

Jorge Nocedal and Stephen J. Wright. Numerical Optimization. Springer, 2nd edition, 2006.

[Păt10]

Mihai Pătraşcu. Towards polynomial lower bounds for dynamic problems. In Proceedings of the 42nd ACM Symposium on Theory of Computing (STOC 2010), pages 603–610. ACM, 2010. doi:10.1145/1806689.1806772.

[PSCP02]

Themistoklis Palpanas, Richard Sidle, Roberta Cochrane, and Hamid Pirahesh. Incremental maintenance for non-distributive aggregate functions. In Proceedings of the 28th International Conference on Very Large Data Bases (VLDB 2002), pages 802–813. Morgan Kaufmann, 2002. doi:10.1016/B978-155860869-6/50076-7.

[Raţ26]

Ovidiu Raţa. Faster linear-space data structures for path frequency queries. In Proceedings of the 20th Scandinavian Symposium on Algorithm Theory (SWAT 2026), pages 37:1–37:17. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2026. doi:10.4230/LIPIcs.SWAT. 2026.37.

[RSBD01]

Miguel Ángel Ruiz-Sánchez, Ernst W. Biersack, and Walid Dabbous. Survey and taxonomy of IP address lookup algorithms. IEEE Network, 15(2):8–23, 2001. doi: 10.1109/65.912716.

[SAKK+ 18]

Verena J. Schuenemann, Charlotte Avanzi, Ben Krause-Kyora, Alexander Seitz, Alexander Herbig, Sarah Inskip, Marion Bonazzi, Ella Reiter, Christian Urban, Dorthe Dangvard Pedersen, G. Michael Taylor, Pushpendra Singh, Graham R. Stewart, Petr Velemínský, Jakub Likovsky, Antónia Marcsik, Erika Molnár, György Pálfi, Valentina Mariotti, Alessandro Riga, M. Giovanna Belcastro, Jesper L. Boldsen, Almut Nebel, Simon Mays, Helen D. Donoghue, Sonia Zakrzewski, Andrej Benjak, Kay Nieselt, Stewart T. Cole, and Johannes Krause. Ancient genomes reveal a high diversity of Mycobacterium leprae in medieval europe. PLOS Pathogens, 14(5):e1006997, 2018. doi:10.1371/journal. ppat.1006997.

[ST81]

Daniel Dominic Sleator and Robert Endre Tarjan. A data structure for dynamic trees. In Proceedings of the 13th Annual ACM Symposium on Theory of Computing (STOC 1981), pages 114–122. ACM, 1981. doi:10.1145/800076.802464.

[SX20]

Bryce Sandlund and Yinzhan Xu. Faster dynamic range mode. In Proceedings of the 47th International Colloquium on Automata, Languages, and Programming (ICALP 2020), pages 94:1–94:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2020. doi:10.4230/LIPIcs.ICALP.2020.94.

27

[THSW15]

Kanat Tangwongsan, Martin Hirzel, Scott Schneider, and Kun-Lung Wu. General incremental sliding-window aggregation. Proceedings of the VLDB Endowment, 8(7):702– 713, 2015. doi:10.14778/2752939.2752940.

[Ukk95]

Esko Ukkonen. On-line construction of suffix trees. Algorithmica, 14(3):249–260, 1995. doi:10.1007/BF01206331.

[VNLK22]

Adrian Vogelsgesang, Thomas Neumann, Viktor Leis, and Alfons Kemper. Efficient evaluation of arbitrarily-framed holistic SQL aggregates and window functions. In Proceedings of the 2022 International Conference on Management of Data (SIGMOD 2022), pages 1243–1256. ACM, 2022. doi:10.1145/3514221.3526184.

[VW18]

Virginia Vassilevska Williams and R. Ryan Williams. Subcubic equivalences between path, matrix, and triangle problems. Journal of the ACM, 65(5):27:1–27:38, 2018. doi:10.1145/3186893.

[VX20]

Virginia Vassilevska Williams and Yinzhan Xu. Truly subcubic min-plus product for less structured matrices, with applications. In Proceedings of the 2020 ACM-SIAM Symposium on Discrete Algorithms (SODA 2020), pages 12–29. SIAM, 2020. doi: 10.1137/1.9781611975994.2.

[WHN22]

Mathias Witte Paz, Theresa A. Harbig, and Kay Nieselt. Evidente—a visual analytics tool for data enrichment in SNP-based phylogenetic trees. Bioinformatics Advances, 2(1):vbac075, 2022. doi:10.1093/bioadv/vbac075.

[WL11]

E. O. Wiley and Bruce S. Lieberman. Phylogenetics: Theory and Practice of Phylogenetic Systematics. Wiley-Blackwell, 2nd edition, 2011. doi:10.1002/9781118017883.

[WX16]

Richard Wesley and Fei Xu. Incremental computation of common windowed holistic aggregates. Proceedings of the VLDB Endowment, 9(12):1221–1232, 2016. doi:10. 14778/2994509.2994537.

[ZBT+ 26]

Jialong Zhou, Ben Bals, Matei Tinca, Ai Guan, Panagiotis Charalampopoulos, Grigorios Loukides, and Solon P. Pissis. Subtree mode and applications. In Proceedings of the 42nd IEEE International Conference on Data Engineering (ICDE 2026), pages 3152–3167. IEEE, 2026. doi:10.1109/ICDE65706.2026.00233.

[ZCG16]

Cheng Zhou, Boris Cule, and Bart Goethals. Pattern based sequence classification. IEEE Transactions on Knowledge and Data Engineering, 28(5):1285–1298, 2016. doi: 10.1109/TKDE.2015.2510010.

28

A

Top-1 Document Retrieval with Document Additions

In the Top-1 Document Retrieval problem [Mut02], we are asked to preprocess a collection S of documents, so that given a query pattern 𝑃, we can output the document in which 𝑃 occurs most frequently. Here, we explain how to solve this problem under document additions [NN17]. We identify the color 𝑖 ∈ Δ with the document 𝑆𝑖 , so that |Δ| = |S|. We build the generalized suffix tree of S from left to right with Ukkonen’s algorithm [Ukk95]. Appending a character 𝑐 to 𝑆𝑖 triggers zero or more updates, each of which (i) attaches a new leaf colored 𝑖 through a new edge starting with 𝑐, or (ii) splits an edge with a new internal node and attaches a new leaf colored 𝑖 to it through a 𝑐-edge. Subdividing an edge inserts a unary internal node and takes O (log 𝑛) time by the Euler-sequence extension in the proof of Theorem 7.1. Attaching the new colored leaf then takes O (log2 𝑛) time. Thus each structural update takes O (log2 𝑛) time, where 𝑛 denotes the total length of S including its sentinels. Since Ukkonen’s algorithm creates O (𝑛) nodes in O (𝑛 log 𝑛) time, maintaining the augmented structure takes O (𝑛 log2 𝑛) time in total and O (𝑛) space. Once 𝑆𝑖 and its sentinel $𝑖 have been appended, every suffix of 𝑆𝑖 is represented by a leaf, so we can spell any pattern 𝑃 of length 𝑚, reach its locus 𝑣, and query the subtree mode of 𝑣, which is the top-1 document for 𝑃 [ZBT+ 26], in O (𝑚 log 𝑛 + |Δ| log2 𝑛) time (Theorem 7.1). If the locus is implicit on an edge, we query its lower endpoint, which has the same leaf descendants. For |Δ| = O (1), this matches, up to log O (1) 𝑛 factors, the query and update bounds of the O (𝑛)-space data structure of [NN17], which, however, solves the Top-𝐾 counterpart and is significantly more involved.

B

Additional Material for Experimental Evaluation

B.1

Details About the Datasets

To construct Amazon, we retain products with a supplied category path and a rating before 1 January 2014. When a product has multiple paths, we select the deepest one, breaking ties lexicographically. Shared category prefixes become internal nodes, and products become leaves. Product colors are derived from the smallest positive supplied sales rank, grouped into bands of width 1 000. This gives 3 802 colors, including a separate color for products without a supplied rank. Because ranks are category-specific, these colors serve as benchmark labels rather than a universal measure of sales volume.

B.2

Additional Results for DSM on News and Genes-sam

Figure 12 shows the additional results for varying 𝛼 on News and Genes-sam. Figure 13 shows the additional results for varying 𝑛 on News and Genes-sam under W100 . Figure 14 shows the additional results for varying 𝑛 on News and Genes-sam under W1/100 . Figure 15 shows the additional results for varying |Δ| on News and Genes-sam under W100 . Figure 16 shows the additional results for varying |Δ| on News and Genes-sam under W1/100 .

B.3

Additional Results for DSM for the Impact of 𝑛

Figure 17 reports the additional construction-time and space results omitted from the main text.

B.4

Additional Results for the Impact of Color Count

Figure 18 reports the construction and space results omitted from the main text.

B.5

Additional Results for FDSM on WebKB

Figure 19 reports query/recoloring results under W100 ; Figures 20 and 21 report structural updates. Within each figure, (a)–(c) vary 𝑛 with |Δ| = 50, and (d)–(f) vary |Δ| with 𝑛 = 35 429 531. The 𝑛-axis tick labels use millions (M); the exact sizes are 8 857 383, 17 714 766, 26 572 148, and 35 429 531.

29

5

10

3

10

1

10

−1

10

−3

0.0

0.2

0.4

10

5

10

3

10

1

Update

Query

Runtime (µs/op)

Runtime (µs/op)

Query

α

0.6

0.8

1.0

10

−1

10

−3

0.0

Runtime (ms)

Peak memory (MiB)

Construction Peak memory

600

300 400

150

200 0

0.0

0.2

0.4

α

0.6

0.4

α

0.6

0.8

1.0

(b) Genes-sam

0.8

1.0

Runtime (ms)

(a) News

0.2

Update

Construction Peak memory

3000

1800 1200

2000

600

1000

0

0

Peak memory (MiB)

10

0.0

(c) News

0.2

0.4

α

0.6

0.8

1.0

0

(d) Genes-sam

10

3

10

1

10

DSM

DRM

SCM-rebuild

−1

10

5

10

3

10

1

10

162.21K 352.84K 540.20K 728.31K

n

3

10

2

10

1

DRM

SCM-rebuild

TO 304.75K 873.22K

n

1.82M

1.82M

3.72M

10

4

10

3

10

2

10

1

DSM

3.72M

(d) Genes-sam

10

4

10

3

10

2

10

1

DSM

DRM

SCM-rebuild

162.21K 352.84K 540.20K 728.31K

n

(e) News

DRM

SCM-rebuild

162.21K 352.84K 540.20K 728.31K

n

(b) Genes-sam Peak memory (MiB)

Runtime (ms)

10

DSM

SCM-rebuild

TO 304.75K 873.22K

(a) News 4

DRM

−1

n

10

DSM

Runtime (ms)

5

(c) News Peak memory (MiB)

10

Runtime (µs/op)

Runtime (µs/op)

Figure 12: Impact of 𝛼 on News and Genes-sam. (a)–(b) query and update time; (c)–(d) construction time (left axis) and space (right axis).

10

4

10

3

10

2

10

1

DSM

DRM

SCM-rebuild

TO 304.75K 873.22K

n

1.82M

3.72M

(f) Genes-sam

Figure 13: Impact of 𝑛 on News and Genes-sam under W100 . (a)–(b) average operation time; (c)–(d) construction time; (e)–(f) space. TO denotes a 24-hour time-out.

30

4

10

2

10

0

SCM-rebuild

TO

TO

162.21K 352.84K 540.20K 728.31K

10

DSM

6

10

4

10

2

10

0

10

3

10

2

10

1

DSM

DRM

SCM-rebuild

TO 304.75K 873.22K

n

n

TO 1.82M

TO 3.72M

10

4

10

3

10

2

10

1

DSM

TO 1.82M

TO 3.72M

10

4

10

3

10

2

10

1

DSM

DRM

TO

TO

n

TO

162.21K 352.84K 540.20K 728.31K

10

4

10

3

10

2

10

1

DSM

DRM

(e) News

SCM-rebuild

TO 304.75K 873.22K

n

(d) Genes-sam

SCM-rebuild

(c) News

SCM-rebuild

TO

DRM

162.21K 352.84K 540.20K 728.31K

(b) Genes-sam Peak memory (MiB)

Runtime (ms)

(a) News 4

SCM-rebuild

TO 304.75K 873.22K

n

10

DRM

Runtime (ms)

10

DRM

Peak memory (MiB)

DSM

6

Runtime (µs/op)

Runtime (µs/op)

10

n

TO 1.82M

TO 3.72M

(f) Genes-sam

10

3

10

1

10

DSM

DRM

SCM-rebuild

−1

1.20K

2.39K

3.59K

|Δ|

10

5

10

3

10

1

10

4.78K

10

3

10

2

10

1

DSM

2.00K

DRM

4.00K

SCM-rebuild

5.00K

|Δ|

SCM-rebuild

2.00K

4.00K

5.00K

|Δ|

10.00K

10

4

10

3

10

2

10

1

DSM

1.20K

(b) Genes-sam

10.00K

(d) Genes-sam

Peak memory (MiB)

Runtime (ms)

4

DRM

−1

(a) News 10

DSM

Runtime (ms)

5

10

3

10

2

10

1

DSM

1.20K

DRM

2.39K

SCM-rebuild

3.59K

|Δ|

(e) News

4.78K

DRM

2.39K

SCM-rebuild

3.59K

|Δ|

4.78K

(c) News Peak memory (MiB)

10

Runtime (µs/op)

Runtime (µs/op)

Figure 14: Impact of 𝑛 on News and Genes-sam under W1/100 . (a)–(b) average operation time; (c)–(d) construction time; (e)–(f) space. TO denotes a 24-hour time-out.

10

3

10

2

10

1

DSM

2.00K

DRM

4.00K

SCM-rebuild

5.00K

|Δ|

10.00K

(f) Genes-sam

Figure 15: Impact of |Δ| on News and Genes-sam under W100 . (a)–(b) average operation time; (c)–(d) construction time; (e)–(f) space.

31

4

10

2

10

0

SCM-rebuild

TO 1.20K

TO

TO

2.39K

3.59K

TO 4.78K

|Δ|

10 10

4

10

2

10

0

2.00K

4

10

3

10

2

10

1

DSM

2.00K

DRM

SCM-rebuild

4.00K

DRM

SCM-rebuild

4.00K

5.00K

|Δ|

10.00K

10

4

10

3

10

2

10

1

DSM

TO 1.20K

(b) Genes-sam Peak memory (MiB)

Runtime (ms)

(a) News 10

DSM

6

Runtime (ms)

10

DRM

5.00K

10.00K

|Δ|

10

3

10

2

10

1

DSM

TO 1.20K

(d) Genes-sam

DRM

SCM-rebuild

TO

TO

2.39K

3.59K

|Δ|

DRM

SCM-rebuild

TO

TO

2.39K

3.59K

|Δ|

TO 4.78K

(c) News

TO 4.78K

Peak memory (MiB)

DSM

6

Runtime (µs/op)

Runtime (µs/op)

10

10

3

10

2

10

1

DSM

2.00K

(e) News

DRM

SCM-rebuild

4.00K

5.00K

|Δ|

10.00K

(f) Genes-sam

Figure 16: Impact of |Δ| on News and Genes-sam under W1/100 . (a)–(b) average operation time; (c)–(d) construction time; (e)–(f) space. TO denotes a 24-hour time-out.

5

10

4

DSM

TO

64.49M

TO

10

10

n

2

(a) Vir

5

10

4

10

6

10

5

10

4

TO

126.27M 254.97M 385.99M 519.28M

64.49M

(d) Genes

10

4

10

3

DRM

TO

64.49M

TO

TO

135.50M 209.77M 287.83M

n

DSM

10

3

10

2

10

1

(g) Vir 6

10

5

10

4

10

3

DSM

5

10

4

10

3

8.86M

10

4

10

3

10

2

10

1

10

6

TO

TO

TO

TO

818.60K

1.05M

2.18M

4.69M

10

5

10

4

10

3

TO

126.27M 254.97M 385.99M 519.28M

n

(j) Genes

DSM

64.49M

(k) Vir

26.57M

n

35.43M

DRM

n

10

5

10

4

10

3

10

2

8.86M

DSM

DRM

17.71M

26.57M

n

35.43M

(i) WebKB

DRM

135.50M 209.77M 287.83M

n

17.71M

(f) Amazon SCM-rebuild

n

DRM

217.86K 433.14K 648.26K 863.32K

n

DRM

DSM

DSM

(h) WebKB-sam DRM

Peak memory (MiB)

Peak memory (MiB)

135.50M 209.77M 287.83M

Peak memory (MiB)

10

10

(e) Vir Peak memory (MiB)

Peak memory (MiB)

DSM

6

(c) WebKB

DRM

6

5

10

TO 4.69M

DSM

n

10

TO 2.18M

n

10

(b) WebKB-sam

6

10

TO 1.05M

DSM

Peak memory (MiB)

10

7

TO 818.60K

DRM

Runtime (ms)

Runtime (ms)

10

DSM

SCM-rebuild

3

TO

135.50M 209.77M 287.83M

DRM

Runtime (ms)

10

DRM

Runtime (ms)

6

Runtime (ms)

Runtime (ms)

DSM

10

10

3

10

2

10

1

DRM

217.86K 433.14K 648.26K 863.32K

n

(l) Amazon

Figure 17: Additional results for the impact of 𝑛. (a)–(f) report construction time and (g)–(l) construction space. (a) and (g) use W100 ; the remaining panels use W1/100 . TO indicates a 24-hour run time-out.

32

TO

TO

TO

TO

36K

72K

108K

144K

5

|Δ|

3

10

2

TO

6K

10

6

10

5

222K

|Δ|

444K

887K

4

TO

TO

TO

TO

36K

72K

108K

144K

|Δ|

10

3

10

6

10

5

36K

10

2

10

1

DSM

10

5

10

4

222K

|Δ|

72K

4

6K

12K

|Δ|

108K

144K

10

DRM

444K

887K

15K

30K

10

4

10

3

10

2

DSM

478

884

DRM

3.8K

7.3K

|Δ|

32K

(f) Amazon SCM-rebuild

TO

TO

12K

|Δ|

DRM

(c) WebKB

DRM

DRM

TO

6K

15K

30K

10

5

10

4

10

3

DSM

6K

12K

|Δ|

DRM

15K

30K

(i) WebKB

6

DSM

10

5

10

4

TO

111K

10

(h) WebKB-sam

DSM

Peak memory (MiB)

Peak memory (MiB)

6

5

|Δ|

(g) Vir 10

30K

DRM

DSM

Peak memory (MiB)

10

DRM

Peak memory (MiB)

Peak memory (MiB)

DSM

5

10

DSM

(e) Vir

6

10

TO

15K

DSM

(d) Genes 10

TO

12K

DRM

TO

111K

6

(b) WebKB-sam

DSM

Runtime (ms)

Runtime (ms)

7

10 SCM-rebuild

|Δ|

(a) Vir 10

DRM

Runtime (ms)

DSM

Runtime (ms)

10

6

10

Peak memory (MiB)

10

DRM

Runtime (ms)

Runtime (ms)

DSM

36K

(j) Genes

72K

|Δ|

108K

144K

10

3

10

2

10

1

(k) Vir

478

884

DRM

3.8K

|Δ|

7.3K

32K

(l) Amazon

DRM

0

8.9M 17.7M 26.6M 35.4M

10

2

10

1

10

0

FDSM

DSM

8.9M 17.7M 26.6M 35.4M

n

10

DSM

DRM

2

0

5

10

25

j¢j

1

10

0

10

50 100

(d) Avg. op. time

10

2

10

1

10

0

FDSM

5

DSM

10

25

j¢j

DSM

DRM

−1

8.9M 17.7M 26.6M 35.4M

n

(b) Construction time Build (s)

Time (¹s/op)

FDSM

FDSM

10

n

(a) Avg. op. time 10

DRM

Peak space (GiB)

10

DSM

2

DRM

50 100

(e) Construction time

Peak space (GiB)

FDSM

10

Build (s)

Time (¹s/op)

Figure 18: Additional results for the impact of |Δ|. (a)–(f) report construction time and (g)–(l) construction space. (a) and (g) use W100 ; the other panels use W1/100 . TO indicates a 24-hour run time-out.

(c) Space FDSM

10

1

10

0

10

DSM

DRM

−1

5

10

25

50 100

j¢j

(f) Space

Figure 19: Query/recoloring experiments on WebKB under W100 , comparing FDSM, DSM, and DRM. (a)–(c) varying 𝑛; (d)–(f) varying |Δ|.

33

20 0 8.9M 17.7M 26.6M 35.4M

7.5 5.0 2.5 0.0 8.9M 17.7M 26.6M 35.4M

n Remove

40 20 0

5

10

25

3.0 1.5 0.0 8.9M 17.7M 26.6M 35.4M

(d) Avg. op. time

7.5 5.0 2.5 0.0

50 100

j¢j

n

(b) Construction time Build (s)

Time (¹s/op)

Add

4.5

n

(a) Avg. op. time 60

Peak space (GiB)

Remove

40

5

10

25

50 100

Peak space (GiB)

Add

Build (s)

Time (¹s/op)

60

(c) Space 4.5 3.0 1.5 0.0

j¢j

5

10

25

50 100

j¢j

(e) Construction time

(f) Space

160 80 0 8.9M 17.7M 26.6M 35.4M

7.5 5.0 2.5 0.0 8.9M 17.7M 26.6M 35.4M

240 160 80 5

10

25

j¢j

3.0 1.5 0.0 8.9M 17.7M 26.6M 35.4M

50 100

(d) Move time

n

(b) Construction time Build (s)

Time (¹s/op)

(a) Move time

0

4.5

n

7.5 5.0 2.5 0.0

5

10

25

j¢j

50 100

(e) Construction time

Peak space (GiB)

n

Peak space (GiB)

240

Build (s)

Time (¹s/op)

Figure 20: Leaf additions and deletions with FDSM on WebKB. (a)–(c) varying 𝑛; (d)–(f) varying |Δ|.

(c) Space 4.5 3.0 1.5 0.0

5

10

25

50 100

j¢j

(f) Space

Figure 21: Subtree moves with FDSM on WebKB. (a)–(c) varying 𝑛; (d)–(f) varying |Δ|.

34

Related documents

Record · ID 1802076 · SHA-256 3beb337634c17e7d
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Bring this data into your agent: Connect via MCP or API · 20 free credits to start · no card required
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive