Skip to main content

All-Pairs Suffix-Prefix on Dynamic Set of Strings

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

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 14899))

Included in the following conference series:

  • 180 Accesses

Abstract

The all-pairs suffix-prefix (APSP) problem is a classical problem in string processing which has important applications in bioinformatics. Given a set \(\mathcal {S} = \{S_1, \ldots , S_k\}\) of k strings, the APSP problem asks one to compute the longest suffix of \(S_i\) that is a prefix of \(S_j\) for all \(k^2\) ordered pairs \(\langle S_i, S_j \rangle \) of strings in \(\mathcal {S}\). In this paper, we consider the dynamic version of the APSP problem that allows for insertions of new strings to the set of strings. Our objective is, each time a new string \(S_i\) arrives to the current set \(\mathcal {S}_{i-1} = \{S_1, \ldots , S_{i-1}\}\) of \(i-1\) strings, to compute (1) the longest suffix of \(S_i\) that is a prefix of \(S_j\) and (2) the longest prefix of \(S_i\) that is a suffix of \(S_j\) for all \(1 \le j \le i\). We propose an O(n)-space data structure which computes (1) and (2) in \(O(|S_i| \log \sigma + i)\) time for each new given string \(S_i\), where n is the total length of the strings.

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.

    We do not use the output function in our algorithms.

References

  1. Abouelhoda, M.I., Kurtz, S., Ohlebusch, E.: Replacing suffix trees with enhanced suffix arrays. J. Discrete Algorithms 2(1), 53–86 (2004)

    Article  MathSciNet  Google Scholar 

  2. Aho, A.V., Corasick, M.J.: Efficient string matching: an aid to bibliographic search. Commun. ACM 18, 333–340 (1975)

    Article  MathSciNet  Google Scholar 

  3. Alstrup, S., Holm, J., de Lichtenberg, K., Thorup, M.: Minimizing diameters of dynamic trees. In: Degano, P., Gorrieri, R., Marchetti-Spaccamela, A. (eds.) ICALP 1997. LNCS, vol. 1256, pp. 270–280. Springer, Heidelberg (1997). https://doi.org/10.1007/3-540-63165-8_184

    Chapter  Google Scholar 

  4. Blumer, A., Blumer, J., Haussler, D., Ehrenfeucht, A., Chen, M.T., Seiferas, J.I.: The smallest automaton recognizing the subwords of a text. Theoret. Comput. Sci. 40, 31–55 (1985)

    Article  MathSciNet  Google Scholar 

  5. Blumer, A., Blumer, J., Haussler, D., McConnell, R., Ehrenfeucht, A.: Complete inverted files for efficient text retrieval and analysis. J. ACM 34(3), 578–595 (1987). https://doi.org/10.1145/28869.28873

    Article  MathSciNet  Google Scholar 

  6. Cánovas, R., Cazaux, B., Rivals, E.: The compressed overlap index. CoRR arXiv:1707.05613 (2017)

  7. Dori, S., Landau, G.M.: Construction of Aho Corasick automaton in linear time for integer alphabets. Inf. Process. Lett. 98(2), 66–72 (2006)

    Article  MathSciNet  Google Scholar 

  8. Farach-Colton, M., Ferragina, P., Muthukrishnan, S.: On the sorting-complexity of suffix tree construction. J. ACM 47(6), 987–1011 (2000)

    Article  MathSciNet  Google Scholar 

  9. Gusfield, D.: Algorithms on Strings, Trees, and Sequences - Computer Science and Computational Biology. Cambridge University Press (1997)

    Google Scholar 

  10. Gusfield, D., Landau, G.M., Schieber, B.: An efficient algorithm for the all pairs suffix-prefix problem. Inf. Process. Lett. 41(4), 181–185 (1992)

    Article  MathSciNet  Google Scholar 

  11. Hendrian, D., Inenaga, S., Yoshinaka, R., Shinohara, A.: Efficient dynamic dictionary matching with DAWGs and AC-automata. Theor. Comput. Sci. 792, 161–172 (2019)

    Article  MathSciNet  Google Scholar 

  12. Khan, S.: Optimal construction of hierarchical overlap graphs. In: CPM 2021. LIPIcs, vol. 191, pp. 17:1–17:11 (2021)

    Google Scholar 

  13. Knuth, D.E., Morris, J.H., Jr., Pratt, V.R.: Fast pattern matching in strings. SIAM J. Comput. 6(2), 323–350 (1977)

    Article  MathSciNet  Google Scholar 

  14. Lim, J., Park, K.: A fast algorithm for the all-pairs suffix-prefix problem. Theor. Comput. Sci. 698, 14–24 (2017)

    Article  MathSciNet  Google Scholar 

  15. Loukides, G., Pissis, S.P.: All-pairs suffix/prefix in optimal time using Aho-Corasick space. Inf. Process. Lett. 178, 106275 (2022)

    Article  MathSciNet  Google Scholar 

  16. Loukides, G., Pissis, S.P., Thankachan, S.V., Zuba, W.: Suffix-prefix queries on a dictionary. In: CPM 2023. LIPIcs, vol. 259, pp. 21:1–21:20 (2023)

    Google Scholar 

  17. Manber, U., Myers, E.W.: Suffix arrays: a new method for on-line string searches. SIAM J. Comput. 22(5), 935–948 (1993)

    Article  MathSciNet  Google Scholar 

  18. Ohlebusch, E., Gog, S.: Efficient algorithms for the all-pairs suffix-prefix problem and the all-pairs substring-prefix problem. Inf. Process. Lett. 110(3), 123–128 (2010)

    Article  MathSciNet  Google Scholar 

  19. Park, S., Park, S.G., Cazaux, B., Park, K., Rivals, E.: A linear time algorithm for constructing hierarchical overlap graphs. In: CPM 2021. LIPIcs, vol. 191, pp. 22:1–22:9 (2021)

    Google Scholar 

  20. Takagi, T., Inenaga, S., Arimura, H., Breslauer, D., Hendrian, D.: Fully-online suffix tree and directed acyclic word graph construction for multiple texts. Algorithmica 82(5), 1346–1377 (2020)

    Article  MathSciNet  Google Scholar 

  21. Tustumi, W.H.A., Gog, S., Telles, G.P., Louza, F.A.: An improved algorithm for the all-pairs suffix-prefix problem. J. Discrete Algorithms 37, 34–43 (2016)

    Article  MathSciNet  Google Scholar 

  22. Weiner, P.: Linear pattern matching algorithms. In: 14th Annual Symposium on Switching and Automata Theory, pp. 1–11 (1973)

    Google Scholar 

  23. Westbrook, J.R.: Fast incremental planarity testing. In: ICALP 1992. Lecture Notes in Computer Science, vol. 623, pp. 342–353 (1992)

    Google Scholar 

Download references

Acknowledgments

This work was supported by JSPS KAKENHI Grant Numbers and JP20H05964, JP23K24808, JP23K18466 (SI).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Shunsuke Inenaga .

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

Kikuchi, M., Inenaga, S. (2025). All-Pairs Suffix-Prefix on Dynamic Set of Strings. 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_15

Download citation

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

  • 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