Skip to main content

Space-Efficient SLP Encoding for O(log N)-Time Random Access

  • Conference paper
  • First Online:
String Processing and Information Retrieval (SPIRE 2024)

Abstract

A Straight-Line Program (SLP) \(\mathcal {G}\) for a string \(\mathcal {T}\) is a context-free grammar (CFG) that derives \(\mathcal {T}\) only, which can be considered as a compressed representation of \(\mathcal {T}\).In this paper, we show how to encode \(\mathcal {G}\) in \(n \lceil \lg N \rceil + (n + n') \lceil \lg (n+\sigma ) \rceil + 4n - 2n' + o(n)\) bits to support random access queries of extracting \(\mathcal {T}[p..q]\) in worst-case \(O(\log N + q - p)\) time, where N is the length of \(\mathcal {T}\), \(\sigma \) is the alphabet size, n is the number of variables in \(\mathcal {G}\) and \(n' \le n\) is the number of symmetric centroid paths in the DAG representation for \(\mathcal {G}\).

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Note that \( in\_rank \) queries in [11] work only for the nodes that have at least two children.

References

  1. Belazzougui, D., Cording, P.H., Puglisi, S.J., Tabei, Y.: Access, rank, and select in grammar-compressed strings. In: Proceedings 23rd Annual European Symposium on Algorithms (ESA) 2015, pp. 142–154 (2015)

    Google Scholar 

  2. Bille, P., Landau, G.M., Raman, R., Sadakane, K., Satti, S.R., Weimann, O.: Random access to grammar-compressed strings and trees. SIAM J. Comput. 44(3), 513–539 (2015)

    Article  MathSciNet  Google Scholar 

  3. Gagie, T., et al.: Practical random access to SLP-compressed texts. In: Proc. 27th International Symposium on String Processing and Information Retrieval (SPIRE) 2020. Lecture Notes in Computer Science, vol. 12303, pp. 221–231. Springer (2020). https://doi.org/10.1007/978-3-030-59212-7_16

  4. Ganardi, M.: Compression by contracting straight-line programs. In: Mutzel, P., Pagh, R., Herman, G. (eds.) Proceedings 29th Annual European Symposium on Algorithms (ESA) 2021. LIPIcs, vol. 204, pp. 451–4516. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2021). https://doi.org/10.4230/LIPIcs.ESA.2021.45, https://doi.org/10.4230/LIPIcs.ESA.2021.45

  5. Ganardi, M., Jez, A., Lohrey, M.: Balancing straight-line programs. J. ACM 68(4), 271–2740 (2021)

    Google Scholar 

  6. Larsson, N.J., Moffat, A.: Offline dictionary-based compression. In: Proceedings Data Compression Conference (DCC) 1999, pp. 296–305 (1999). https://doi.org/10.1109/DCC.1999.755679, https://doi.org/10.1109/DCC.1999.755679

  7. Lempel, A., Ziv, J.: On the complexity of finite sequences. IEEE Trans. Inf. Theory 22(1), 75–81 (1976). https://doi.org/10.1109/TIT.1976.1055501, https://doi.org/10.1109/TIT.1976.1055501

  8. Lohrey, M.: Algorithmics on SLP-compressed strings: a survey. Groups Complex. Cryptology 4(2), 241–299 (2012)

    Article  MathSciNet  Google Scholar 

  9. Maruyama, S., Tabei, Y., Sakamoto, H., Sadakane, K.: Fully-online grammar compression. In: Proceedings 20th International Symposium on String Processing and Information Retrieval (SPIRE) 2013, pp. 218–229 (2013). https://doi.org/10.1007/978-3-319-02432-5_25

  10. Morrison, D.R.: PATRICIA - practical algorithm to retrieve information coded in alphanumeric. J. ACM 15(4), 514–534 (1968). https://doi.org/10.1145/321479.321481

  11. Navarro, G., Sadakane, K.: Fully functional static and dynamic succinct trees. ACM Trans. Algorithms 10(3), 16 (2014). https://doi.org/10.1145/2601073

  12. Raman, R., Raman, V., Satti, S.R.: Succinct indexable dictionaries with applications to encoding k-ARY trees, prefix sums and multisets. ACM Trans. Algorithms 3(4) (2007). https://doi.org/10.1145/1290672.1290680

  13. Tabei, Y., Takabatake, Y., Sakamoto, H.: A succinct grammar compression. In: Proceedings 24th Annual Symposium on Combinatorial Pattern Matching (CPM) 2013. Lecture Notes in Computer Science, vol. 7922, pp. 235–246. Springer (2013). https://doi.org/10.1007/978-3-642-38905-4_23

  14. Takabatake, Y., I, T., Sakamoto, H.: A space-optimal grammar compression. In: Proceedings 25th Annual European Symposium on Algorithms (ESA) 2017. LIPIcs, vol. 87, pp. 671–6715. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2017). https://doi.org/10.4230/LIPICS.ESA.2017.67

  15. Verbin, E., Yu, W.: Data structure lower bounds on random access to grammar-compressed strings. In: Proceedings 24th Annual Symposium on Combinatorial Pattern Matching (CPM) 2013, pp. 247–258 (2013)

    Google Scholar 

  16. Willard, D.E.: Log-logarithmic worst-case range queries are possible in space theta(n). Inf. Process. Lett. 17(2), 81–84 (1983). https://doi.org/10.1016/0020-0190(83)90075-3

    Article  Google Scholar 

  17. Ziv, J., Lempel, A.: A universal algorithm for sequential data compression. IEEE Trans. Inf. Theory 23(3), 337–343 (1977). https://doi.org/10.1109/TIT.1977.1055714

Download references

Acknowledgements

This work was supported by JSPS KAKENHI (Grant Numbers 22K11907 and 24K02899) and JST AIP Acceleration Research JPMJCR24U4, Japan.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Tomohiro I .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2025 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Takasaka, A., I, T. (2025). Space-Efficient SLP Encoding for O(log N)-Time Random Access. In: Lipták, Z., Moura, E., Figueroa, K., Baeza-Yates, R. (eds) String Processing and Information Retrieval. SPIRE 2024. Lecture Notes in Computer Science, vol 14899. Springer, Cham. https://doi.org/10.1007/978-3-031-72200-4_25

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-72200-4_25

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-72199-1

  • Online ISBN: 978-3-031-72200-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics