, Volume 80, Issue 3, pp 885–917 | Cite as

Tree Compression Using String Grammars

  • Moses Ganardi
  • Danny Hucke
  • Markus Lohrey
  • Eric Noeth
Part of the following topical collections:
  1. Special Issue on Theoretical Informatics


We study the compressed representation of a ranked tree by a (string) straight-line program (SLP) for its preorder traversal, and compare it with the well-studied representation by straight-line context free tree grammars (which are also known as tree straight-line programs or TSLPs). Although SLPs may be exponentially more succinct than TSLPs, we show that many simple tree queries can still be performed efficiently on SLPs, such as computing the height of a tree, tree navigation, or evaluation of Boolean expressions. Other problems on tree traversals turn out to be intractable, e.g. pattern matching and evaluation of tree automata. These problems can be still solved in polynomial time for TSLPs.


Grammar-based compression Tree compression Expression evaluation 



Funding was provided by Deutsche Forschungsgemeinschaft (Grant No. LO 748/10-1)


  1. 1.
    Akutsu, T.: A bisection algorithm for grammar-based compression of ordered trees. Inf. Process. Lett. 110(18–19), 815–820 (2010)MathSciNetCrossRefMATHGoogle Scholar
  2. 2.
    Allender, E., Balaji, N., Datta, S.: Low-depth uniform threshold circuits and the bit-complexity of straight line programs. In: Proceedings of MFCS 2014, Part II, volume 8635 of Lecture Notes in Computer Science, pp. 13–24. Springer (2014)Google Scholar
  3. 3.
    Allender, E., Bürgisser, P., Kjeldgaard-Pedersen, J., Bro Miltersen, P.: On the complexity of numerical analysis. SIAM J. Comput. 38(5), 1987–2006 (2009)MathSciNetCrossRefMATHGoogle Scholar
  4. 4.
    Allender, E., Wagner, K.W.: Counting hierarchies: polynomial time and constant depth circuits. Bull. EATCS 40, 182–194 (1990)MATHGoogle Scholar
  5. 5.
    Bertoni, A., Choffrut, C., Radicioni, R.: Literal shuffle of compressed words. In: Proceedings of IFIP TCS 2008, volume 273 of IFIP, pp. 87–100. Springer (2008)Google Scholar
  6. 6.
    Benoit, D., Demaine, E.D., Munro, J.I., Raman, R., Raman, V., Rao, S.S.: Representing trees of higher degree. Algorithmica 43(4), 275–292 (2005)MathSciNetCrossRefMATHGoogle Scholar
  7. 7.
    Bille, P., Gørtz, I.L., Landau, G.M., Weimann, O.: Tree compression with top trees. Inf. Comput. 243, 166–177 (2015)MathSciNetCrossRefMATHGoogle Scholar
  8. 8.
    Bille, P., Landau, G.M., Raman, R., Sadakane, K., Satti, S.R., Weimann, O.: Random access to grammar-compressed strings and trees. SIAM J. Comput. 44(3), 513–539 (2015)MathSciNetCrossRefMATHGoogle Scholar
  9. 9.
    Bousquet-Mélou, M., Lohrey, M., Maneth, S., Noeth, E.: XML compression via DAGs. Theory Comput. Syst. 57, 1322 (2014)CrossRefMATHGoogle Scholar
  10. 10.
    Busatto, G., Lohrey, M., Maneth, S.: Efficient memory representation of XML document trees. Inf. Syst. 33(4–5), 456–474 (2008)CrossRefMATHGoogle Scholar
  11. 11.
    Buss, S.R.: The Boolean formula value problem is in ALOGTIME. In: Proceedings of STOC 1987, pp. 123–131. ACM Press (1987)Google Scholar
  12. 12.
    Caussinus, H., McKenzie, P., Thérien, D., Vollmer, H.: Nondeterministic \(NC^1\) computation. J. Comput. Syst. Sci. 57(2), 200–212 (1998)MathSciNetCrossRefMATHGoogle Scholar
  13. 13.
    Charikar, M., Lehman, E., Lehman, A., Liu, D., Panigrahy, R., Prabhakaran, M., Sahai, A., Shelat, A.: The smallest grammar problem. IEEE Trans. Inf. Theory 51(7), 2554–2576 (2005)MathSciNetCrossRefMATHGoogle Scholar
  14. 14.
    Comon, H., Dauchet, M., Gilleron, R., Jacquemard, F., Lugiez, D., Löding, Tison, S., Tommasi, M.: Tree automata techniques and applications.
  15. 15.
    Esparza, J., Luttenberger, M., Schlund, M.: A brief history of strahler numbers. In: Proceedings of LATA 2014, volume 8370 of Lecture Notes in Computer Science, pp. 1–13. Springer (2014)Google Scholar
  16. 16.
    Ferragina, P., Luccio, F., Manzini, G., Muthukrishnan, S.: Compressing and indexing labeled trees with applications. J. ACM 57(1), 4 (2009)MathSciNetCrossRefMATHGoogle Scholar
  17. 17.
    Flajolet, P., Raoult, J.-C., Vuillemin, J.: The number of registers required for evaluating arithmetic expressions. Theor. Comput. Sci. 9, 99–125 (1979)MathSciNetCrossRefMATHGoogle Scholar
  18. 18.
    Ganardi, M., Hucke, D., Jeż, A., Lohrey, M., Noeth, E.: Constructing small tree grammars and small circuits for formulas. J. Comput. Syst. Sci. (2017). doi: 10.1016/j.jcss.2016.12.007
  19. 19.
    Ganardi, M., Hucke, D., Lohrey, M., Noeth, E.: Tree compression using string grammars. In: Proceedings of LATIN 2016, volume 9644 of Lecture Notes in Computer Science, pp. 590–604. Springer (2016)Google Scholar
  20. 20.
    Hagenah, C.: Gleichungen mit regulären Randbedingungen über freien Gruppen. PhD thesis, University of Stuttgart, Institut für Informatik (2000)Google Scholar
  21. 21.
    Hesse, W., Allender, E., Mix Barrington, D.A.: Uniform constant-depth threshold circuits for division and iterated multiplication. J. Comput. Syst. Sci. 65, 695–716 (2002)MathSciNetCrossRefMATHGoogle Scholar
  22. 22.
    Hübschle-Schneider, L., Raman, R.: Tree compression with top trees revisited. In: Proceedings of SEA 2015, volume 9125 of Lecture Notes in Computer Science, pp. 15–27. Springer (2015)Google Scholar
  23. 23.
    Hucke, D., Lohrey, M., Noeth, E.: Constructing small tree grammars and small circuits for formulas. In: Proceedings of FSTTCS 2014, volume 29 of LIPIcs, pp. 457–468. Schloss Dagstuhl-Leibniz-Zentrum für Informatik, (2014)Google Scholar
  24. 24.
    Jacobson, G.: Space-efficient static trees and graphs. In: Proceedings of FOCS 1989, pp. 549–554. IEEE Computer Society (1989)Google Scholar
  25. 25.
    Jansson, J., Sadakane, K., Sung, W.-K.: Ultra-succinct representation of ordered trees with applications. J. Comput. Syst. Sci. 78(2), 619–631 (2012)MathSciNetCrossRefMATHGoogle Scholar
  26. 26.
    Jeż, A.: Approximation of grammar-based compression via recompression. Theor. Comput. Sci. 592, 115–134 (2015)MathSciNetCrossRefMATHGoogle Scholar
  27. 27.
    Jeż, A.: Faster fully compressed pattern matching by recompression. ACM Trans. Algorithms 11(3), 20:1–20:43 (2015)MathSciNetMATHGoogle Scholar
  28. 28.
    Jeż, A.: A really simple approximation of smallest grammar. Theor. Comput. Sci. 616, 141–150 (2016)MathSciNetCrossRefMATHGoogle Scholar
  29. 29.
    Jeż, A., Lohrey, M.: Approximation of smallest linear tree grammars. In Procedings of STACS 2014, volume 25 of LIPIcs, pp. 445–457. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2014)Google Scholar
  30. 30.
    Kobayashi, N., Matsuda, K., Shinohara, A.: Functional programs as compressed data. In: Proceedings of PEPM 2012, pp. 121–130. ACM Press (2012)Google Scholar
  31. 31.
    Lohrey, M.: On the parallel complexity of tree automata. In: Proceedings of RTA 2001, volume 2051 of Lecture Notes in Computer Science, pp. 201–215. Springer (2001)Google Scholar
  32. 32.
    Lohrey, M.: Leaf languages and string compression. Inf. Comput. 209(6), 951–965 (2011)MathSciNetCrossRefMATHGoogle Scholar
  33. 33.
    Lohrey, M.: The Compressed Word Problem for Groups. Springer, Berlin (2014)CrossRefMATHGoogle Scholar
  34. 34.
    Lohrey, M.: Grammar-based tree compression. In: Proceedings of DLT 2015, volume 9168 of Lecture Notes in Computer Science, pp. 46–57. Springer (2015)Google Scholar
  35. 35.
    Lohrey, M., Maneth, S.: The complexity of tree automata and XPath on grammar-compressed trees. Theor. Comput. Sci. 363(2), 196–210 (2006)MathSciNetCrossRefMATHGoogle Scholar
  36. 36.
    Lohrey, M., Maneth, S., Mennicke, R.: XML tree structure compression using RePair. Inf. Syst. 38(8), 1150–1167 (2013)CrossRefGoogle Scholar
  37. 37.
    Lohrey, M., Maneth, S., Schmidt-Schauß, M.: Parameter reduction and automata evaluation for grammar-compressed trees. J. Comput. Syst. Sci. 78(5), 1651–1669 (2012)MathSciNetCrossRefMATHGoogle Scholar
  38. 38.
    Lohrey, M., Mathissen, C.: Isomorphism of regular trees and words. Inf. Comput. 224, 71–105 (2013)MathSciNetCrossRefMATHGoogle Scholar
  39. 39.
    Munro, J.I., Raman, V.: Succinct representation of balanced parentheses and static trees. SIAM J. Comput. 31(3), 762–776 (2001)MathSciNetCrossRefMATHGoogle Scholar
  40. 40.
    Navarro, G., Ordó nez Pereira, A.: Faster compressed suffix trees for repetitive text collections. In: Proceedings of SEA 2014, volume 8504 of Lecture Notes in Computer Science, pp. 424–435. Springer (2014)Google Scholar
  41. 41.
    Rytter, W.: Application of Lempel-Ziv factorization to the approximation of grammar-based compression. Theor. Comput. Sci. 302(1–3), 211–222 (2003)MathSciNetCrossRefMATHGoogle Scholar
  42. 42.
    Sakamoto, H.: A fully linear-time approximation algorithm for grammar-based compression. J. Discrete Algorithms 3(2–4), 416–430 (2005)MathSciNetCrossRefMATHGoogle Scholar
  43. 43.
    Schmidt-Schauß, M.: Linear compressed pattern matching for polynomial rewriting (extended abstract). In: Proceedings of TERMGRAPH 2013, volume 110 of EPTCS, pp. 29–40 (2013)Google Scholar
  44. 44.
    Toda, S.: PP is as hard as the polynomial-time hierarchy. SIAM J. Comput. 20(5), 865–877 (1991)MathSciNetCrossRefMATHGoogle Scholar
  45. 45.
    Vollmer, H.: Introduction to Circuit Complexity. Springer, Berlin (1999)CrossRefMATHGoogle Scholar

Copyright information

© Springer Science+Business Media New York 2017

Authors and Affiliations

  • Moses Ganardi
    • 1
  • Danny Hucke
    • 1
  • Markus Lohrey
    • 1
  • Eric Noeth
    • 1
  1. 1.Universität SiegenSiegenGermany

Personalised recommendations