Skip to main content
Log in

Data Structures for Computing Unique Palindromes in Static and Non-Static Strings

  • Published:
Algorithmica Aims and scope Submit manuscript

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 [pq] if T[i..j] is a shortest palindromic substring such that T[i..j] occurs only once in T, and [ij] contains [pq]. 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.

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
Fig. 6
Fig. 7
Fig. 8

Similar content being viewed by others

Notes

  1. Since MUPSs cannot be nested [23], they are also sorted by their ending positions.

  2. This is inspired by a similar notion defined for minimal unique substrings in [33].

References

  1. 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

    Article  MathSciNet  Google Scholar 

  2. 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

  3. Amir, A., Boneh, I.: Dynamic palindrome detection. (2019) CoRR abs/1906.09732. arxiv:1906.09732

  4. 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

  5. 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

  6. 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

    Article  MathSciNet  Google Scholar 

  7. 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

    Article  Google Scholar 

  8. 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

  9. 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

  10. Clark, D.: Compact Pat Trees. PhD thesis, University of Waterloo (1997)

  11. 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

    Article  Google Scholar 

  12. 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

    Article  MathSciNet  Google Scholar 

  13. 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

    Article  Google Scholar 

  14. 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

    Article  Google Scholar 

  15. 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

    Article  MathSciNet  Google Scholar 

  16. 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

    Article  MathSciNet  Google Scholar 

  17. 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

  18. 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

    Article  MathSciNet  Google Scholar 

  19. 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)

    Chapter  Google Scholar 

  20. 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

  21. 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

    Article  MathSciNet  Google Scholar 

  22. Gusfield, D.: Algorithms on Strings, Trees, and Sequences - Computer Science and Computational Biology. Cambridge University Press (1997). https://doi.org/10.1017/cbo9780511574931

  23. 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

    Article  MathSciNet  Google Scholar 

  24. 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

  25. 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

  26. 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

    Article  CAS  PubMed  PubMed Central  Google Scholar 

  27. 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

  28. 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

    Article  Google Scholar 

  29. 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

    Article  MathSciNet  Google Scholar 

  30. 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

    Article  MathSciNet  Google Scholar 

  31. 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

    Article  MathSciNet  Google Scholar 

  32. Senft, M.: Suffix tree for a sliding window: an overview. WDS 2005, 41–46 (2005)

    Google Scholar 

  33. 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

  34. Ukkonen, E.: On-line construction of suffix trees. Algorithmica 14(3), 249–260 (1995). https://doi.org/10.1007/BF01206331

    Article  MathSciNet  Google Scholar 

  35. 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

  36. 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

    Article  MathSciNet  Google Scholar 

  37. 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)

    Article  CAS  PubMed  Google Scholar 

  38. 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

    Article  MathSciNet  Google Scholar 

Download references

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

Authors

Corresponding author

Correspondence to Takuya Mieno.

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.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

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

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-023-01170-8

Keywords

Navigation