An efficient algorithm for the All Pairs Suffix-Prefix Problem

Dan Gusfield, Gad M. Landau, Baruch Schieber

Research output: Contribution to journalArticlepeer-review


For a pair of strings (S1, S2), define the suffix-prefix match of (S1, S2) to be the longest suffix of string S1 that matches a prefix of string S2. The following problem is considered in this paper. Given a collection of strings S1, S2,...,Sk of total length m, find the suffix-prefix match for each of the k(k - 1) ordered pairs of strings. We present an algorithm that solves the problem in O(m + k2) time, for any fixed alphabet. Since the size of the input is Ω(m) and the size of the output is Ω(k2) this solution is optimal.

Original languageEnglish
Pages (from-to)181-185
Number of pages5
JournalInformation Processing Letters
Issue number4
StatePublished - 18 Mar 1992
Externally publishedYes

Bibliographical note

Funding Information:
Correspondence to: Professor G.M. Landau, Department of Computer Science, Polytechnic University, 333 Jay Street, Brooklyn, NY 11201, USA. Tel.: +l 718 260 3154, email: * Partially supported by Department of Energy grant DE-FG03-90ER60999, and NSF grant CCR-8803704. Tel.: + 1 916 752 7131, email: * * Partially supported by NSF grant CCR-8908286. * * * Tel.: + 1 914 945 1169, email:


  • Design of algorithms
  • string matching
  • suffix tree

ASJC Scopus subject areas

  • Theoretical Computer Science
  • Signal Processing
  • Information Systems
  • Computer Science Applications


Dive into the research topics of 'An efficient algorithm for the All Pairs Suffix-Prefix Problem'. Together they form a unique fingerprint.

Cite this