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.
Similar content being viewed by others
Notes
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.
It is possible that α = 0 for some intervals.
References
Apostolico, A., Breslauer, D., Galil, Z.: Parallel detection of all palindromes in a string. Theor Comput. Sci. 141(1&2), 163–173 (1995)
Beame, P., Fich, F.E.: Optimal bounds for the predecessor problem and related problems. J. Comput. Syst. Sci. 65(1), 38–72 (2002)
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)
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)
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)
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)
Hu, X., Pei, J., Tao, Y.: Shortest unique queries on strings. In: SPIRE 2014, pp. 161–172 (2014)
Ileri, A.M., Külekci, M.O., Xu, B.: Shortest unique substring query revisited. In: CPM 2014, pp. 172–181 (2014)
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)
Manacher, G.: A new linear-time “on-line” algorithm for finding the smallest initial palindrome of a string. J. ACM 22, 346–351 (1975)
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)
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)
Pei, J., Wu, W.C.-H., Yeh, M.-Y.: On Shortest Unique Substring Queries. In: Proc. ICDE 2013, pp. 937–948 (2013)
Rubinchik, M., Shur, A.M.: Eertree: an efficient data structure for processing palindromes in strings. Eur. J. Comb. 68, 249–265 (2018)
Tsuruta, K., Inenaga, S., Bannai, H., Takeda, M.: Shortest unique substrings queries in optimal time. In: Proc. SOFSEM 2014, pp. 503–513 (2014)
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)
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
Corresponding author
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
About this article
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
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00224-020-09980-x