All-pairs suffix/prefix in optimal time using Aho-Corasick space

Grigorios Loukides, Solon P. Pissis*

*Corresponding author for this work

Research output: Contribution to JournalArticleAcademicpeer-review

Abstract

The all-pairs suffix/prefix (APSP) problem is a classic problem in computer science with many applications in bioinformatics. Given a set {S1,…,Sk} of k strings of total length n, we are asked to find, for each string Si, i∈[1,k], its longest suffix that is a prefix of string Sj, for all j≠i, j∈[1,k]. Several algorithms running in the optimal O(n+k2) time for solving APSP are known. All of these algorithms are based on suffix sorting and thus require space Ω(n) in any case. We consider the parameterized version of the APSP problem, denoted by ℓ-APSP, in which we are asked to output only the pairs whose suffix/prefix overlap is of length at least ℓ. We give an algorithm for solving ℓ-APSP that runs in the optimal O(n+|OUTPUT|) time using O(n) space, where OUTPUT is the set of output pairs. Our algorithm is thus optimal for the APSP problem as well by setting ℓ=0. Notably, our algorithm is fundamentally different from all optimal algorithms solving the APSP problem: it does not rely on sorting the suffixes of all input strings but on a novel traversal of the Aho-Corasick machine, and it thus requires space linear in the size of the machine.

Original languageEnglish
Article number106275
Pages (from-to)1-6
Number of pages6
JournalInformation Processing Letters
Volume178
Early online date28 Apr 2022
DOIs
Publication statusPublished - Nov 2022

Bibliographical note

Funding Information:
The authors would like to thank Anne Luesink (Vrije Universiteit) for implementing the algorithm underlying Theorem 1 . The source code is freely available at https://github.com/ALuesink/APSP_algorithm . Grigorios Loukides is partially supported by the Leverhulme Trust RPG-2019-399 project. Solon P. Pissis is partially supported by the PANGAIA and ALPACA projects that have received funding from the European Union's Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreements No 872539 and 956229 , respectively.

Publisher Copyright:
© 2022 The Authors

Funding

The authors would like to thank Anne Luesink (Vrije Universiteit) for implementing the algorithm underlying Theorem 1 . The source code is freely available at https://github.com/ALuesink/APSP_algorithm . Grigorios Loukides is partially supported by the Leverhulme Trust RPG-2019-399 project. Solon P. Pissis is partially supported by the PANGAIA and ALPACA projects that have received funding from the European Union's Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreements No 872539 and 956229 , respectively.

FundersFunder number
ALPACA
PANGAIA
Horizon 2020 Framework Programme
H2020 Marie Skłodowska-Curie Actions872539, 956229
Leverhulme TrustRPG-2019-399
Horizon 2020

    Keywords

    • Aho-Corasick machine
    • Algorithms
    • Data structures
    • Failure transition tree
    • String algorithms

    Fingerprint

    Dive into the research topics of 'All-pairs suffix/prefix in optimal time using Aho-Corasick space'. Together they form a unique fingerprint.

    Cite this