## The heaviest induced ancestors problem: better data structures and applications.(English)Zbl 07549531

Summary: Let $$\mathcal{T}_1$$ and $$\mathcal{T}_2$$ be two rooted trees with an equal number of leaves. The leaves are labeled, and the labeling of the leaves in $$\mathcal{T}_2$$ is a permutation of those in $$\mathcal{T}_1$$. Nodes are associated with weight, such that the weight of a node $$u$$, denoted by $$W(u)$$, is more than the weight of its parent. A node $$x \in\mathcal{T}_1$$ and a node $$y \in\mathcal{T}_2$$ are induced, iff their subtrees have at least one common leaf label. A heaviest induced ancestor query $$\mathsf{HIA} (u_1,u_2)$$ with input nodes $$u_1 \in\mathcal{T}_1$$ and $$u_2 \in\mathcal{T}_2$$ asks to output the pair $$(u_1^*,u_2^*)$$ of induced nodes with the highest combined weight $$\mathsf{W} (u^*_1) + \mathsf{W} (u^*_2)$$, such that $$u_1^*$$ is an ancestor of $$u_1$$ and $$u^*_2$$ is an ancestor of $$u_2$$. This is a useful primitive in several text processing applications. Gagie et al. (Proceedings of the 25th Canadian Conference on Computational Geometry, CCCG 2013, Waterloo, Ontario, Canada, 2013) introduced this problem and proposed three data structures with the following space-time trade-offs: (i) $$O(n\log^2n)$$ space and $$O(\log n \log \log n)$$ query time, (ii) $$O(n\log n)$$ space and $$O(\log^2 n)$$ query time, and (iii) $$O(n)$$ space and $$O(\log^{3+\epsilon}n)$$ query time. Here $$n$$ is the number of nodes in both trees combined and $$\epsilon >0$$ is an arbitrarily small constant. We present two new data structures with better space-time trade-offs: (i) $$O(n\log n)$$ space and $$O(\log n \log \log n)$$ query time, and (ii) $$O(n)$$ space and $$O({\log^2 n}/{\log \log n})$$ query time. Additionally, we present new applications of these results.

### MSC:

 68P05 Data structures 68W32 Algorithms on strings

### Keywords:

data structure; string algorithms; orthogonal range queries
Full Text: