Skip to main content
Log in

Fast Algorithms for the Shortest Unique Palindromic Substring Problem on Run-Length Encoded Strings

  • Published:
Theory of Computing Systems Aims and scope Submit manuscript

Abstract

For a string S, a palindromic substring S[i..j] is said to be a shortest unique palindromic substring (SUPS) for an interval [s,t] in S, if S[i..j] occurs exactly once in S, the interval [i,j] contains [s,t], and every palindromic substring containing [s,t] which is shorter than S[i..j] occurs at least twice in S. In this paper, we study the problem of answering SUPS queries on run-length encoded strings. We show how to preprocess a given run-length encoded string RLES of size m in O(m) space and \(O(m \log \sigma _{\mathit {RLE}_{S}} + m \sqrt {\log m / \log \log m})\) time so that all SUPSs for any subsequent query interval can be answered in \(O(\sqrt {\log m / \log \log m} + \alpha )\) time, where α is the number of outputs, and \(\sigma _{\mathit {RLE}_{S}}\) is the number of distinct runs of RLES. Additionaly, we consider a variant of the SUPS problem where a query interval is also given in a run-length encoded form. For this variant of the problem, we present two alternative algorithms with faster queries. The first one answers queries in \(O(\sqrt {\log \log m /\log \log \log m} + \alpha )\) time and can be built in \(O(m \log \sigma _{\mathit {RLE}_{S}} + m \sqrt {\log m / \log \log m})\) time, and the second one answers queries in \(O(\log \log m + \alpha )\) time and can be built in \(O(m \log \sigma _{\mathit {RLE}_{S}})\) time. Both of these data structures require O(m) space.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5

Similar content being viewed by others

Notes

  1. Throughout this paper, we measure the space complexity of an algorithm with the number of words that the algorithm occupies in the word RAM model, unless otherwise stated.

  2. It is possible that α = 0 for some intervals.

References

  1. Apostolico, A., Breslauer, D., Galil, Z.: Parallel detection of all palindromes in a string. Theor Comput. Sci. 141(1&2), 163–173 (1995)

    MATH  Google Scholar 

  2. Beame, P., Fich, F.E.: Optimal bounds for the predecessor problem and related problems. J. Comput. Syst. Sci. 65(1), 38–72 (2002)

    MathSciNet  MATH  Google Scholar 

  3. Bender, M.A., Farach-Colton, M.: The LCA problem revisited. In: Proceedings of the 4th Latin American Symposium on Theoretical Informatics, LATIN 2000, pp. 88–94 (2000)

  4. Droubay, X., Justin, J., Pirillo, G.: Episturmian words and some constructions of de Luca and Rauzy. Theor. Comput. Sci. 255(1-2), 539–553 (2001)

    MathSciNet  MATH  Google Scholar 

  5. Ganguly, A., Hon, W., Shah, R., Thankachan, S.V.: Space-time trade-offs for finding shortest unique substrings and maximal unique matches. Theor. Comput. Sci. 700, 75–88 (2017)

    MathSciNet  MATH  Google Scholar 

  6. Hon, W.-K., Thankachan, S.V., Xu, B.: An in-place framework for exact and approximate shortest unique substring queries. In: ISAAC 2015, pp. 755–767 (2015)

  7. Hu, X., Pei, J., Tao, Y.: Shortest unique queries on strings. In: SPIRE 2014, pp. 161–172 (2014)

  8. Ileri, A.M., Külekci, M.O., Xu, B.: Shortest unique substring query revisited. In: CPM 2014, pp. 172–181 (2014)

  9. Inoue, H., Nakashima, Y., Mieno, T., Inenaga, S., Bannai, H., Takeda, M.: Algorithms and combinatorial properties on shortest unique palindromic substrings. Journal of Discrete Algorithms 52-53, 122–132 (2018)

    MathSciNet  MATH  Google Scholar 

  10. Manacher, G.: A new linear-time “on-line” algorithm for finding the smallest initial palindrome of a string. J. ACM 22, 346–351 (1975)

    MATH  Google Scholar 

  11. Matsubara, W., Inenaga, S., Ishino, A., Shinohara, A., Nakamura, T., Hashimoto, K.: Efficient algorithms to compute compressed longest common substrings and compressed palindromes. Theor. Comput. Sci. 410(8), 900–913 (2009)

    MathSciNet  MATH  Google Scholar 

  12. Mieno, T., Inenaga, S., Bannai, H., Takeda, M.: Shortest unique substring queries on run-length encoded strings. In: Proc. MFCS 2016, pp. 69:1–69:11 (2016)

  13. Pei, J., Wu, W.C.-H., Yeh, M.-Y.: On Shortest Unique Substring Queries. In: Proc. ICDE 2013, pp. 937–948 (2013)

  14. Rubinchik, M., Shur, A.M.: Eertree: an efficient data structure for processing palindromes in strings. Eur. J. Comb. 68, 249–265 (2018)

    MathSciNet  MATH  Google Scholar 

  15. Tsuruta, K., Inenaga, S., Bannai, H., Takeda, M.: Shortest unique substrings queries in optimal time. In: Proc. SOFSEM 2014, pp. 503–513 (2014)

  16. Watanabe, K., Nakashima, Y., Inenaga, S., Bannai, H., Takeda, M.: Shortest unique palindromic substring queries on run-length encoded strings. In: IWOCA 2019, pp. 430–441 (2019)

Download references

Acknowledgments

This work was supported by JSPS KAKENHI Grant Numbers JP18K18002 (YN), JP17H01697 (SI), JP16H02783 (HB), JP18H04098 (MT), and by JST PRESTO Grant Number JPMJPR1922 (SI).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kiichi Watanabe.

Additional information

Publisher’s Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This article belongs to the Topical Collection: Special Issue on International Workshop on Combinatorial Algorithms (IWOCA 2019)

Guest Editors: Charles Colbourn, Roberto Grossi, Nadia Pisanti

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Watanabe, K., Nakashima, Y., Inenaga, S. et al. Fast Algorithms for the Shortest Unique Palindromic Substring Problem on Run-Length Encoded Strings. Theory Comput Syst 64, 1273–1291 (2020). https://doi.org/10.1007/s00224-020-09980-x

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00224-020-09980-x

Keywords

Navigation