Path Queries in Weighted Trees
We consider the problem of supporting several different path queries over a tree on n nodes, each having a weight drawn from a set of σ distinct values, where σ ≤ n. One query we support is the path median query, which asks for the median weight on a path between two given nodes. For this and the more general path selection query, we present a linear space data structure that answers queries in \(O(\lg \sigma)\) time under the word RAM model. This greatly improves previous results on the same problem, as previous data structures achieving \(O(\lg n)\) query time use \(O(n \lg^2 n)\) space, and previous linear space data structures require O(n ε ) time to answer a query for any positive constant ε . Our linear space data structure also supports path counting queries in \(O(\lg \sigma)\) time. This matches the result of Chazelle  when σ is close to n, but has better performance when σ is significantly smaller than n. Finally, the same data structure can also support path reporting queries in \(O(\lg \sigma + occ \lg \sigma)\) time, where occ is the size of output. In addition, we present a data structure that answers path reporting queries in \(O(\lg \sigma + occ \lg\lg\sigma)\) time, using \(O(n\lg\lg\sigma)\) space. These are the first data structures that answer path reporting queries.
KeywordsQuery Time Weight Tree Path Query Space Cost Range Tree
Unable to display preview. Download preview PDF.
- 1.Alon, N., Schieber, B.: Optimal preprocessing for answering on-line product querie. Tech. rep., Tel Aviv University (1987)Google Scholar
- 6.Chan, T.M., Larsen, K.G., Pǎtraşcu, M.: Orthogonal range searching on the RAM, revisited. In: Symposium on Computational Geometry, pp. 1–10 (2011)Google Scholar
- 7.Chan, T.M., Pǎtraşcu, M.: Counting inversions, offline orthogonal range counting, and related problems. In: SODA, pp. 161–173 (2010)Google Scholar
- 12.Grossi, R., Gupta, A., Vitter, J.S.: High-order entropy-compressed text indexes. In: SODA, pp. 841–850 (2003)Google Scholar
- 15.Jørgensen, A.G., Larsen, K.G.: Range selection and median: Tight cell probe lower bounds and adaptive data structures. In: SODA, pp. 805–813 (2011)Google Scholar
- 17.Pǎtraşcu, M.: Lower bounds for 2-dimensional range counting. In: STOC, pp. 40–46 (2007)Google Scholar
- 18.Pǎtraşcu, M.: (Data) Structures. In: FOCS, pp. 434–443 (2008)Google Scholar