Constrained LCS: Hardness and Approximation

  • Zvi Gotthilf
  • Danny Hermelin
  • Moshe Lewenstein
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5029)


The problem of finding the longest common subsequence (LCS) of two given strings A 1 and A 2 is a well-studied problem. The constrained longest common subsequence (C-LCS) for three strings A 1, A 2 and B 1 is the longest common subsequence of A 1 and A 2 that contains B 1 as a subsequence. The fastest algorithm solving the C-LCS problem has a time complexity of O(m 1 m 2 n 1) where m 1, m 2 and n 1 are the lengths of A 1, A 2 and B 1 respectively. In this paper we consider two general variants of the C-LCS problem. First we show that in case of two input strings and an arbitrary number of constraint strings, it is NP-hard to approximate the C-LCS problem. Moreover, it is easy to see that in case of an arbitrary number of input strings and a single constraint, the problem of finding the constrained longest common subsequence is NP-hard. Therefore, we propose a linear time approximation algorithm for this variant, our algorithm yields a \(1 / \sqrt{m_{min}|\Sigma|}\) approximation factor, where m min is the length of the shortest input string and |Σ| is the size of the alphabet.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aho, A.V., Hirschberg, D.S., Ullman, J.D.: Bounds on the Complexity of the Longest Common Subsequence Problem. Journal of the ACM 23(1), 1–12 (1976)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Arslan, A.N., Egecioglu, Ö.: Algorithms For The Constrained Longest Common Subsequence Problems. International Journal of Foundations of Computer Science 16(6), 1099–1109 (2005)zbMATHCrossRefMathSciNetGoogle Scholar
  3. 3.
    Bergroth, L., Hakonen, H., Raita, T.: A Survey of Longest Common Subsequence Algorithms. In: Proc. SPIRE 2000, pp. 39–48 (2000)Google Scholar
  4. 4.
    Chin, F.Y.L., De Santis, A., Ferrara, A.L., Ho, N.L., Kim, S.K.: A simple algorithm for the constrained sequence problems. Information Processing Letters 90(4), 175–179 (2004)CrossRefMathSciNetGoogle Scholar
  5. 5.
    Gotthilf, Z., Lewenstein, M.: Approximating Constrained LCS. In: Ziviani, N., Baeza-Yates, R. (eds.) SPIRE 2007. LNCS, vol. 4726, pp. 164–172. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  6. 6.
    Hirschberg, D.S.: A Linear Space Algorithm for Computing Maximal Common Subsequences. Communications of the ACM 18(6), 341–343 (1975)zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Hirschberg, D.S.: Algorithms for the Longest Common Subsequence Problem. Journal of the ACM 24(4), 664–675 (1977)zbMATHCrossRefMathSciNetGoogle Scholar
  8. 8.
    Maier, D.: The Complexity of Some Problems on Subsequences and Supersequences. Journal of the ACM 25(2), 322–336 (1978)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Masek, W.J., Paterson, M.: A Faster Algorithm Computing String Edit Distances. Journal of Computer and System Sciences 20(1), 18–31 (1980)zbMATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Tsai, Y.-T.: The constrained longest common subsequence problem. Information Processing Letters 88(4), 173–176 (2003)CrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Zvi Gotthilf
    • 1
  • Danny Hermelin
    • 2
  • Moshe Lewenstein
    • 1
  1. 1.Department of Computer ScienceBar-Ilan UniversityRamat GanIsrael
  2. 2.Department of Computer ScienceUniversity of Haifa, Mount CarmelHaifaIsrael

Personalised recommendations