Abstract
A palindromic substring T[i..j] of a string T is said to be a shortest unique palindromic substring (SUPS) in T for an interval [p, q] if T[i..j] is a shortest palindromic substring such that T[i..j] occurs only once in T, and [i, j] contains [p, q]. The SUPS problem is, given a string T of length n, to construct a data structure that can compute all the SUPSs for any given query interval. It is known that any SUPS query can be answered in \(O(\alpha )\) time after O(n)-time preprocessing, where \(\alpha \) is the number of SUPSs to output (Inoue in J Discrete Algorithms 52-53:122–132, 2018). In this paper, we first show that \(\alpha \) is at most 4, and the upper bound is tight. We also show that the total sum of lengths of minimal unique palindromic substrings of string T, which is strongly related to SUPSs, is O(n). Then, we present the first O(n)-bits data structures that can answer any SUPS query in constant time. Also, we present an algorithm to solve the SUPS problem for a sliding window that can answer any query in \(O(\log \log W)\) time and update data structures in amortized \(O(\log \sigma + \log \log W)\) time, where W is the size of the window, and \(\sigma \) is the alphabet size. Furthermore, we consider the SUPS problem in the after-edit model and present an efficient algorithm. Namely, we present an algorithm that uses O(n) time for preprocessing and answers any k SUPS queries in \(O(\log n\log \log n + k\log \log n)\) time after single character substitution. Finally, as a by-product, we propose a fully-dynamic data structure for range minimum queries (RmQs) with a constraint where the width of each query range is limited to poly-logarithmic. The constrained RmQ data structure can answer such a query in constant time and support a single-element edit operation in amortized constant time.
Similar content being viewed by others
References
Abedin, P., Hooshmand, S., Ganguly, A., et al.: The heaviest induced ancestors problem: better data structures and applications. Algorithmica 84(7), 2088–2105 (2022). https://doi.org/10.1007/s00453-022-00955-7
Alstrup, S., Husfeldt, T., Rauhe, T. Marked ancestor problems. In: 39th Annual Symposium on Foundations of Computer Science, FOCS ’98, November 8-11, 1998, Palo Alto, California, USA. IEEE Computer Society, 534–544, (1998) https://doi.org/10.1109/SFCS.1998.743504
Amir, A., Boneh, I.: Dynamic palindrome detection. (2019) CoRR abs/1906.09732. arxiv:1906.09732
Amir, A., Charalampopoulos, P., Iliopoulos, C.S., et al.: Longest common factor after one edit operation. In: Fici G, Sciortino M, Venturini R (eds) String Processing and Information Retrieval - 24th International Symposium, SPIRE 2017, Palermo, Italy, September 26-29, 2017, Proceedings, Lecture Notes in Computer Science, vol 10508. Springer, 14–26, (2017) https://doi.org/10.1007/978-3-319-67428-5_2
Amir, A., Boneh, I., Charalampopoulos, P., et al.: Repetition detection in a dynamic string. In: Bender MA, Svensson O, Herman G (eds) 27th Annual European Symposium on Algorithms, ESA 2019, September 9-11, 2019, Munich/Garching, Germany, LIPIcs, vol 144. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 5:1–5:18, (2019) https://doi.org/10.4230/LIPIcs.ESA.2019.5
Amir, A., Charalampopoulos, P., Pissis, S.P., et al.: Dynamic and internal longest common substring. Algorithmica 82(12), 3707–3743 (2020). https://doi.org/10.1007/s00453-020-00744-0
Apostolico, A., Breslauer, D., Galil, Z.: Parallel detection of all palindromes in a string. Theor. Comput. Sci. 141(1 &2), 163–173 (1995). https://doi.org/10.1016/0304-3975(94)00083-U
Brodal, G.S., Davoodi, P., Rao, S.S.: Path minima queries in dynamic weighted trees. In: Dehne F, Iacono J, Sack J (eds) Algorithms and Data Structures - 12th International Symposium, WADS 2011, New York, USA, Aug 15-17, 2011. Proceedings, Lecture Notes in Computer Science, vol 6844. Springer, 290–301, (2011) https://doi.org/10.1007/978-3-642-22300-6_25
Charalampopoulos, P., Gawrychowski, P., Pokorski, K.: Dynamic longest common substring in polylogarithmic time. In: Czumaj A, Dawar A, Merelli E (eds) 47th International Colloquium on Automata, Languages, and Programming, ICALP 2020, Jul 8-11, 2020, Saarbrücken, Germany (Virtual Conference), LIPIcs, vol 168. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 27:1–27:19, (2020) https://doi.org/10.4230/LIPIcs.ICALP.2020.27
Clark, D.: Compact Pat Trees. PhD thesis, University of Waterloo (1997)
Cleary, J.G., Witten, I.H.: Data compression using adaptive coding and partial string matching. IEEE Trans. Commun. 32(4), 396–402 (1984). https://doi.org/10.1109/TCOM.1984.1096090
Crochemore, M., Héliou, A., Kucherov, G., et al.: Absent words in a sliding window with applications. Inf. Comput. (2020). https://doi.org/10.1016/j.ic.2019.104461
van Emde, Boas P.: Preserving order in a forest in less than logarithmic time and linear space. Inf. Process. Lett. 6(3), 80–82 (1977). https://doi.org/10.1016/0020-0190(77)90031-X
Fiala, E.R., Greene, D.H.: Data compression with finite windows. Commun. ACM 32(4), 490–505 (1989). https://doi.org/10.1145/63334.63341
Fine, N.J., Wilf, H.S.: Uniqueness theorems for periodic functions. Proc. Am. Math. Soc. 16(1), 109–114 (1965). https://doi.org/10.1090/S0002-9939-1965-0174934-9
Fischer, J., Heun, V.: Space-efficient preprocessing schemes for range minimum queries on static arrays. SIAM J. Comput. 40(2), 465–492 (2011). https://doi.org/10.1137/090779759
Funakoshi, M., Mieno, T.: Minimal unique palindromic substrings after single-character substitution. In: Lecroq T, Touzet H (eds) String Processing and Information Retrieval - 28th International Symposium, SPIRE 2021, Lille, France, October 4-6, 2021, Proceedings, Lecture Notes in Computer Science, vol 12944. Springer, 33–46, (2021) https://doi.org/10.1007/978-3-030-86692-1_4
Funakoshi, M., Nakashima, Y., Inenaga, S., et al.: Computing longest palindromic substring after single-character or block-wise edits. Theor. Comput. Sci. 859, 116–133 (2021). https://doi.org/10.1016/j.tcs.2021.01.014
Gasieniec, L., Karpinski, M., Plandowski, W., et al.: Efficient algorithms for Lempel-Ziv encoding. In: Karlsson, R., Lingas, A. (eds.) Algorithm theory – SWAT’96, pp. 392–403. Springer, Berlin Heidelberg (1996)
Gawrychowski, P., Karczmarz, A., Kociumaka, T., et al.: Optimal dynamic strings. In: Czumaj A (ed) Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2018, New Orleans, LA, USA, January 7-10, 2018. SIAM, 1509–1528, (2018) https://doi.org/10.1137/1.9781611975031.99
Gawrychowski, P., Merkurev, O., Shur, A.M., et al.: Tight tradeoffs for real-time approximation of longest palindromes in streams. Algorithmica 81(9), 3630–3654 (2019). https://doi.org/10.1007/s00453-019-00591-8
Gusfield, D.: Algorithms on Strings, Trees, and Sequences - Computer Science and Computational Biology. Cambridge University Press (1997). https://doi.org/10.1017/cbo9780511574931
Inoue, H., Nakashima, Y., Mieno, T., et al.: Algorithms and combinatorial properties on shortest unique palindromic substrings. J. Dis. Algorithms 52–53, 122–132 (2018). https://doi.org/10.1016/j.jda.2018.11.009
Jacobson, G.: Space-efficient static trees and graphs. In: 30th Annual Symposium on Foundations of Computer Science, Research Triangle Park, North Carolina, USA, 30 Oct– 1 Nov 1989. IEEE Computer Society, 549–554, (1989) https://doi.org/10.1109/SFCS.1989.63533
Kempa, D., Kociumaka, T.: Dynamic suffix array with polylogarithmic queries and updates. In: Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing. Association for Computing Machinery, New York, USA, STOC 2022, 1657-1670, (2022) https://doi.org/10.1145/3519935.3520061
Kuramoto, E., Yano, O., Kimura, Y., et al.: Oligonucleotide sequences required for natural killer cell activation. Jpn. J. Cancer Res. 83(11), 1128–1131 (1992). https://doi.org/10.1111/j.1349-7006.1992.tb02734.x
Larsson, N.J.: Extended application of suffix trees to data compression. In: Storer JA, Cohn M (eds) Proceedings of the 6th Data Compression Conference (DCC ’96), Snowbird, Utah, USA, March 31 - April 3, 1996. IEEE Computer Society, 190–199, (1996) https://doi.org/10.1109/DCC.1996.488324
Manacher, G.K.: A new linear-time on-line algorithm for finding the smallest initial palindrome of a string. J. ACM 22(3), 346–351 (1975). https://doi.org/10.1145/321892.321896
Matsubara, W., Inenaga, S., Ishino, A., et al.: Efficient algorithms to compute compressed longest common substrings and compressed palindromes. Theor. Comput. Sci. 410(8–10), 900–913 (2009). https://doi.org/10.1016/j.tcs.2008.12.016
Mieno, T., Fujishige, Y., Nakashima, Y., et al.: Computing minimal unique substrings for a sliding window. Algorithmica 84(3), 670–693 (2022). https://doi.org/10.1007/s00453-021-00864-1
Mieno, T., Watanabe, K., Nakashima, Y., et al.: Palindromic trees for a sliding window and its applications. Inf. Process. Lett. 173, 106174 (2022). https://doi.org/10.1016/j.ipl.2021.106174
Senft, M.: Suffix tree for a sliding window: an overview. WDS 2005, 41–46 (2005)
Tsuruta, K., Inenaga, S., Bannai, H., et al.: Shortest unique substrings queries in optimal time. In: SOFSEM 2014: Theory and Practice of Computer Science - 40th International Conference on Current Trends in Theory and Practice of Computer Science, Lecture Notes in Computer Science, vol 8327. Springer, 503–513, (2014)https://doi.org/10.1007/978-3-319-04298-5_44
Ukkonen, E.: On-line construction of suffix trees. Algorithmica 14(3), 249–260 (1995). https://doi.org/10.1007/BF01206331
Urabe, Y., Nakashima, Y., Inenaga, S., et al.: Longest Lyndon substring after edit. In: Navarro G, Sankoff D, Zhu B (eds) Annual Symposium on Combinatorial Pattern Matching, CPM 2018, July 2-4, 2018 - Qingdao, China, LIPIcs, vol 105. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 19:1–19:10, (2018) https://doi.org/10.4230/LIPIcs.CPM.2018.19
Watanabe, K., Nakashima, Y., Inenaga, S., et al.: Fast algorithms for the shortest unique palindromic substring problem on run-length encoded strings. Theor. Comput. Syst. 64(7), 1273–1291 (2020). https://doi.org/10.1007/s00224-020-09980-x
Yamamoto, S., Yamamoto, T., Kataoka, T., et al.: Unique palindromic sequences in synthetic oligonucleotides are required to induce IFN natural killer activity. J. Immunol. 148(12), 4072–4076 (1992)
Ziv, J., Lempel, A.: A universal algorithm for sequential data compression. IEEE Trans. Inf. Theor. 23(3), 337–343 (1977). https://doi.org/10.1109/TIT.1977.1055714
Acknowledgements
We would like to thank Professor Jeffrey Shallit (University of Waterloo) for his interest in our paper and his advice to simplify our proofs. We would also like to thank the anonymous referees for their helpful comments on the manuscript. This work was partially supported by the JSPS KAKENHI Grant Numbers JP20J11983, JP22K21273 (TM), and JP20J21147 (MF).
Author information
Authors and Affiliations
Corresponding author
Ethics declarations
Conflict of interest
The authors declare no conflicts of interest associated with this manuscript.
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.
About this article
Cite this article
Mieno, T., Funakoshi, M. Data Structures for Computing Unique Palindromes in Static and Non-Static Strings. Algorithmica 86, 852–873 (2024). https://doi.org/10.1007/s00453-023-01170-8
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00453-023-01170-8