Reversing Longest Previous Factor Tables is Hard

  • Jing He
  • Hongyu Liang
  • Guang Yang
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6844)


The Longest Previous Factor (LPF) table of a string s of length n is a table of size n whose i th element indicates the length of the longest substring of s starting from position i that has appeared previously in s. LPF tables facilitate the computing of the Lempel-Ziv factorization of strings [21,22] which plays an important role in text compression. An open question from Clément, Crochemore and Rindone [4] asked whether the following problem (which we call the reverse LPF problem) can be solved efficiently: Given a table W, decide whether it is the LPF table of some string, and find such a string if so.

In this paper, we address this open question by proving that the reverse LPF problem is NP-hard. Thus, there is no polynomial time algorithm for solving it unless P = NP. Complementing with this general hardness result, we also design a linear-time online algorithm for the reverse LPF problem over input tables whose elements are all 0 or 1.


Linear Time Variable Section Unary Substring Cover Array Characteristic Segment 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Apostolico, A., Giancarlo, R.: The Boyer-Moore-Galil string searching strategies revisited. SIAM J. Comput. 15(1), 98–105 (1986)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Bannai, H., Inenaga, S., Shinohara, A., Takeda, M.: Inferring strings from graphs and arrays. In: Rovan, B., Vojtáš, P. (eds.) MFCS 2003. LNCS, vol. 2747, pp. 208–217. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  3. 3.
    Boyer, R.S., Moore, J.S.: A fast string searching algorithm. Commin. ACM 20(10), 762–772 (1977)CrossRefzbMATHGoogle Scholar
  4. 4.
    Clément, J., Crochemore, M., Rindone, G.: Reverse engineering prefix tables. In: STACS 2009, Freiburg, pp. 289–300 (2009)Google Scholar
  5. 5.
    Crochemore, M.: Transducers and repetitions. Theoret. Comput. Sci. 45(1), 63–86 (1986)MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Crochemore, M., Hancart, C., Lecroq, T.: Algorithms on strings. Cambridge University Press, Cambridge (2007)CrossRefzbMATHGoogle Scholar
  7. 7.
    Crochemore, M., Ilie, L.: Computing Longest Previous Factor in linear time and applications. Inf. Process. Lett. 106(2), 75–80 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
  8. 8.
    Crochemore, M., Iliopoulos, C.S., Pissis, S.P., Tischler, G.: Cover Array string reconstruction. In: Amir, A., Parida, L. (eds.) CPM 2010. LNCS, vol. 6129, pp. 251–259. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  9. 9.
    Crochemore, M., Lecroq, T.: Tight bounds on the complexity of the Apostolico-Giancarlo algorithm. Inf. Process. Lett. 63(4), 195–203 (1997)MathSciNetCrossRefzbMATHGoogle Scholar
  10. 10.
    Duval, J.-P., Lecroq, T., Lefebvre, A.: Efficient validation and construction of border arrays. In: Proceedings of 11th Mons Days of Theoretical Computer Science, Rennes, France, pp. 179–189 (2006)Google Scholar
  11. 11.
    Franek, F., Gao, S., Lu, W., Ryan, P.J., Smyth, W.F., Sun, Y., Yang, L.: Verifying a Border array in linear time. J. Combinatorial Math. and Combinatorial Computing 42, 223–236 (2002)MathSciNetzbMATHGoogle Scholar
  12. 12.
    Franek, F., Smyth, W.F.: Reconstructing a Suffix Array. International Journal of Foundations of Computer Science 17(6), 1281–1295 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    Gawrychowski, P., Jeż, A., Jeż, Ł.: Validating the Knuth-Morris-Pratt failure function, fast and online. In: Ablayev, F., Mayr, E.W. (eds.) CSR 2010. LNCS, vol. 6072, pp. 132–143. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  14. 14.
    Gusfield, D.: Algorithms on strings, trees and sequences: computer science and computational biology. Cambridge University Press, Cambridge (1997)CrossRefzbMATHGoogle Scholar
  15. 15.
    I., T., Inenaga, S., Bannai, H., Takeda, M.: Verifying a Parameterized Border Array in O(n 1.5) time. In: Amir, A., Parida, L. (eds.) CPM 2010. LNCS, vol. 6129, pp. 238–250. Springer, Heidelberg (2010)Google Scholar
  16. 16.
    Knuth, D.E., Morris, J.H., Pratt, V.R.: Fast pattern matching in strings. SIAM J. Comput. 6(1), 323–350 (1977)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Kolpakov, R., Kucherov, G.: Finding maximal repetitions in a word in linear time. In: FOCS 1999, pp. 596–604. IEEE Computer Society Press, New York (1999)Google Scholar
  18. 18.
    Main, M.G.: Detecting leftmost maximal periodicities. Discrete Applied Math. 25, 145–153 (1989)MathSciNetCrossRefzbMATHGoogle Scholar
  19. 19.
    Manber, U., Myers, G.: Suffix arrays: a new method for on-line search. SIAM J. Comput. 22(5), 935–948 (1993)MathSciNetCrossRefzbMATHGoogle Scholar
  20. 20.
    Matsubara, W., Ishino, A., Shinohara, A.: Inferring strings from runs. In: Prague Stringology Conference 2010, pp. 150–160 (2010)Google Scholar
  21. 21.
    Ziv, J., Lempel, A.: A Universal algorithm for sequential data compression. IEEE Trans. Inform. Theory 23, 337–342 (1977)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Ziv, J., Lempel, A.: Compression of individual sequences via variable-rate coding. IEEE Trans. Inform. Theory 24, 530–536 (1978)MathSciNetCrossRefzbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Jing He
    • 1
  • Hongyu Liang
    • 1
  • Guang Yang
    • 1
  1. 1.IInstitute for Interdisciplinary Information SciencesTsinghua UniversityBeijingChina

Personalised recommendations