Scalable Detection of Frequent Substrings by Grammar-Based Compression

  • Masaya Nakahara
  • Shirou Maruyama
  • Tetsuji Kuboyama
  • Hiroshi Sakamoto
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6926)


A scalable pattern discovery by compression is proposed. A string is representable by a context-free grammar (CFG) deriving the string deterministically. In this framework of grammar-based compression, the aim of the algorithm is to output as small a CFG as possible. Beyond that, the optimization problem is approximately solvable. In such approximation algorithms, the compressor by Sakamoto et al. (2009) is especially suitable for detecting maximal common substrings as well as long frequent substrings. This is made possible thanks to the characteristics of edit-sensitive parsing (ESP) by Cormode and Muthukrishnan (2007), which was introduced to approximate a variant of edit distance. Based on ESP, we design a linear time algorithm to find all frequent patterns in a string approximately and prove a lower bound for the length of extracted frequent patterns. We also examine the performance of our algorithm by experiments in DNA sequences and other compressible real world texts. Compared to the practical algorithm developed by Uno (2008), our algorithm is faster with large and repetitive strings.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Altschul, S.F., Gish, W., Miller, W., Myers, E.W., Lipman, D.J.: Basic local alignment search tool. J. Mol. Biol. 215(3), 403–410 (1990)CrossRefGoogle Scholar
  2. 2.
    Charikar, M., Lehman, E., Liu, D., Panigrahy, R., Prabhakaran, M., Sahai, A., Shelat, A.: The smallest grammar problem. IEEE Transactions on Information Theory 51(7), 2554–2576 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Cilibrasi, R., Vitanyi, P.M.B.: Clustering by compression. IEEE Transactions on Information Theory 51(4), 1523–1545 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Cormode, G., Muthukrishnan, S.: The string edit distance matching problem with moves. ACM Trans. Algor. 3(1), Article 2 (2007)Google Scholar
  5. 5.
    Gusfield, D.: Algorithms on Strings, Trees, and Sequences. Cambridge University Press, Cambridge (1997)CrossRefzbMATHGoogle Scholar
  6. 6.
    Karp, R.M., Miller, R.E., Rosenberg, A.L.: Rapid identification of repeated patterns in strings, trees and arrays. In: STOC 1972, pp. 125–136 (1972)Google Scholar
  7. 7.
    Kieffer, J.C., Yang, E.-H.: Grammar-based codes: A new class of universal lossless source codes. IEEE Transactions on Information Theory 46(3), 737–754 (2000)MathSciNetCrossRefzbMATHGoogle Scholar
  8. 8.
    Lehman, E., Shelat, A.: Approximation algorithms for grammar-based compression. In: SODA 2002, pp. 205–212 (2002)Google Scholar
  9. 9.
    Li, M., Chen, X., Li, X., Ma, B., Vitanyi, P.M.B.: The similarity metric. IEEE Transactions on Information Theory 50(12), 3250–3264 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  10. 10.
    Pearson, W.R.: Flexible sequence similarity searching with the fasta3 program package methods. Mol. Biol. 132, 185–219 (2000)Google Scholar
  11. 11.
    Rytter, W.: Application of Lempel-Ziv factorization to the approximation of grammar-based compression. Theor. Comput. Sci. 302(1-3), 211–222 (2003)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 12.
    Sadakane, K.: Compressed text databases with efficient query algorithms based on the compressed suffix array. In: Lee, D.T., Teng, S.-H. (eds.) ISAAC 2000. LNCS, vol. 1969, pp. 410–421. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  13. 13.
    Sakamoto, H.: A fully linear-time approximation algorithm for grammar-based compression. J. Discrete Algorithms 3(2-4), 416–430 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Sakamoto, H., Maruyama, S., Kida, T., Shimozono, S.: A space-saving approximation algorithm for grammar-based compression. IEICE Trans. on Information and Systems E92-D(2), 158–165 (2009)CrossRefGoogle Scholar
  15. 15.
    Shapira, D., Storer, J.A.: Edit distance with move operations. J. Discrete Algorithms 5(2), 380–392 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Uno, T.: An efficient algorithm for finding similar short substrings from large scale string data. In: Washio, T., Suzuki, E., Ting, K.M., Inokuchi, A. (eds.) PAKDD 2008. LNCS (LNAI), vol. 5012, pp. 345–356. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  17. 17.
    Välimäki, N., Mäkinen, V., Gerlach, W., Dixit, K.: Engineering a compressed suffix tree implementation. ACM Journal of Experimental Algorithmics 14 (2009)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Masaya Nakahara
    • 1
  • Shirou Maruyama
    • 2
  • Tetsuji Kuboyama
    • 3
  • Hiroshi Sakamoto
    • 1
    • 4
  1. 1.Kyushu Institute of TechnologyIizuka-shiJapan
  2. 2.Kyushu UniversityFukuoka-shiJapan
  3. 3.Gakushuin UniversityToshimaJapan
  4. 4.PRESTO JSTKawaguchiJapan

Personalised recommendations