Abstract

Consider an ordinal tree T on n nodes, each of which is assigned a category from an alphabet [σ]={1,2,…,σ}. We preprocess the tree T in order to support categorical path counting queries, which ask for the number of distinct categories occurring on the path in T between two query nodes x and y. For this problem, we propose a linear-space data structure with query time O(nlg⁡lg⁡σlg⁡w), where w=Ω(lg⁡n) is the word size in the word-RAM. As shown in our proof, from the assumption that matrix multiplication cannot be solved in time polynomially faster than cubic (with only combinatorial methods), our result is optimal, save for polylogarithmic speed-ups. For a trade-off parameter 1≤t≤n, we propose an O(n+n2t2)-word, O(tlg⁡lg⁡σlg⁡w) query time data structure. We also consider c-approximate categorical path counting queries, which must return an approximation to the number of distinct categories occurring on the query path, by counting each such category at least once and at most c times. We describe a linear-space data structure that supports 2-approximate categorical path counting queries in O(lg⁡n/lg⁡lg⁡n) time.Next, we generalize the categorical path counting queries to weighted trees. Here, a query specifies two nodes x,y and an orthogonal range Q. The answer to thus formed categorical path range counting query is the number of distinct categories occurring on the path from x to y, if only the nodes with weights falling inside Q are considered. We propose an O(nlg⁡lg⁡n+(n/t)4)-word data structure with O(tlg⁡lg⁡n) query time, or an O(n+(n/t)4)-word data structure with O(tlgϵ⁡n) query time. For an appropriate choice of the trade-off parameter t, this implies a linear-space data structure with O(n3/4lgϵ⁡n) query time. We then extend the approach to the trees weighted with vectors from [n]d, where d is a constant integer greater than or equal to 2. We present a data structure with O(nlgd−1+ϵ⁡n+(n/t)2d+2) words of space and O(tlgd−1⁡n(lg⁡lg⁡n)d−2) query time. For an O(n⋅polylogn)-space solution, one thus has O(n2d+12d+2⋅polylogn) query time.The inherent difficulty revealed by the lower bound we proved motivated us to consider data structures based on sketching. In unweighted trees, we propose a sketching data structure to solve the approximate categorical path counting problem which asks for a (1±ϵ)-approximation (i.e. within 1±ϵ of the true answer) of the number of distinct categories on the given path, with probability 1−δ, where 0<ϵ,δ<1 are constants. The data structure occupies O(n+ntlg⁡n) words of space, for the query time of O(tlg⁡n). For trees weighted with d-dimensional weight vectors (d≥1), we propose a data structure with O((n+ntlg⁡n)lgd⁡n) words of space and O(tlgd+1⁡n) query time.All these problems generalize the corresponding categorical range counting problems in Euclidean space Rd+1, for respective d, by replacing one of the dimensions with a tree topology.

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.