Path Queries in Weighted Trees

  • Meng He
  • J. Ian Munro
  • Gelin Zhou
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7074)

Abstract

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 ε [16]. Our linear space data structure also supports path counting queries in \(O(\lg \sigma)\) time. This matches the result of Chazelle [8] 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.

References

  1. 1.
    Alon, N., Schieber, B.: Optimal preprocessing for answering on-line product querie. Tech. rep., Tel Aviv University (1987)Google Scholar
  2. 2.
    Bender, M.A., Farach-Colton, M.: The LCA Problem Revisited. In: Gonnet, G.H., Viola, A. (eds.) LATIN 2000. LNCS, vol. 1776, pp. 88–94. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  3. 3.
    Bille, P.: A survey on tree edit distance and related problems. Theor. Comput. Sci. 337(1-3), 217–239 (2005)MathSciNetCrossRefMATHGoogle Scholar
  4. 4.
    Brodal, G.S., Gfeller, B., Jørgensen, A.G., Sanders, P.: Towards optimal range medians. Theor. Comput. Sci. 412(24), 2588–2601 (2011)MathSciNetCrossRefMATHGoogle Scholar
  5. 5.
    Brodal, G.S., Jørgensen, A.G.: Data Structures for Range Median Queries. In: Dong, Y., Du, D.-Z., Ibarra, O. (eds.) ISAAC 2009. LNCS, vol. 5878, pp. 822–831. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  6. 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. 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
  8. 8.
    Chazelle, B.: Computing on a free tree via complexity-preserving mappings. Algorithmica 2, 337–361 (1987)MathSciNetCrossRefMATHGoogle Scholar
  9. 9.
    Gagie, T., Puglisi, S.J., Turpin, A.: Range Quantile Queries: Another Virtue of Wavelet Trees. In: Karlgren, J., Tarhio, J., Hyyrö, H. (eds.) SPIRE 2009. LNCS, vol. 5721, pp. 1–6. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  10. 10.
    Geary, R.F., Raman, R., Raman, V.: Succinct ordinal trees with level-ancestor queries. ACM Transactions on Algorithms 2(4), 510–534 (2006)MathSciNetCrossRefMATHGoogle Scholar
  11. 11.
    Gfeller, B., Sanders, P.: Towards Optimal Range Medians. In: Albers, S., Marchetti-Spaccamela, A., Matias, Y., Nikoletseas, S., Thomas, W. (eds.) ICALP 2009. LNCS, vol. 5555, pp. 475–486. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  12. 12.
    Grossi, R., Gupta, A., Vitter, J.S.: High-order entropy-compressed text indexes. In: SODA, pp. 841–850 (2003)Google Scholar
  13. 13.
    Hagerup, T.: Parallel preprocessing for path queries without concurrent reading. Inf. Comput. 158(1), 18–28 (2000)MathSciNetCrossRefMATHGoogle Scholar
  14. 14.
    JáJá, J., Mortensen, C.W., Shi, Q.: Space-Efficient and Fast Algorithms for Multidimensional Dominance Reporting and Counting. In: Fleischer, R., Trippen, G. (eds.) ISAAC 2004. LNCS, vol. 3341, pp. 558–568. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  15. 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
  16. 16.
    Krizanc, D., Morin, P., Smid, M.H.M.: Range mode and range median queries on lists and trees. Nord. J. Comput. 12(1), 1–17 (2005)MathSciNetMATHGoogle Scholar
  17. 17.
    Pǎtraşcu, M.: Lower bounds for 2-dimensional range counting. In: STOC, pp. 40–46 (2007)Google Scholar
  18. 18.
    Pǎtraşcu, M.: (Data) Structures. In: FOCS, pp. 434–443 (2008)Google Scholar
  19. 19.
    Petersen, H.: Improved Bounds for Range Mode and Range Median Queries. In: Geffert, V., Karhumäki, J., Bertoni, A., Preneel, B., Návrat, P., Bieliková, M. (eds.) SOFSEM 2008. LNCS, vol. 4910, pp. 418–423. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  20. 20.
    Petersen, H., Grabowski, S.: Range mode and range median queries in constant time and sub-quadratic space. Inf. Process. Lett. 109(4), 225–228 (2009)MathSciNetCrossRefMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Meng He
    • 1
  • J. Ian Munro
    • 2
  • Gelin Zhou
    • 2
  1. 1.Faculty of Computer ScienceDalhousie UniversityCanada
  2. 2.David R. Cheriton School of Computer ScienceUniversity of WaterlooCanada

Personalised recommendations