Backward Linearised Tree Pattern Matching

  • Jan TrávníčekEmail author
  • Jan Janoušek
  • Bořivoj Melichar
  • Loek Cleophas
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8977)


We present a new backward tree pattern matching algorithm for ordered trees. The algorithm finds all occurrences of a single given tree pattern which match an input tree. It makes use of linearisations of both the given pattern and the input tree. The algorithm preserves the properties and advantages of standard backward string pattern matching approaches. The number of symbol comparisons in the backward tree pattern matching can be sublinear in the size of the input tree. As in the case of backward string pattern matching, the size of the bad character shift table used by the algorithm is linear in the size of the alphabet. We compare the new algorithm with best performing previously existing algorithms based on (non-linearised) tree pattern matching using finite tree automata or stringpath matchers and show that it outperforms these for single pattern matching.


Tree pattern matching Backward pattern matching Tree processing Tree linearisation 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aho, A.V., Ganapathi, M., Tjiang, S.W.K.: Code generation using tree matching and dynamic programming. ACM Trans. Program. Lang. Syst., 491–516 (1989)Google Scholar
  2. 2.
    Aho, A.V., Ullman, J.D.: The theory of parsing, translation, and compiling. Prentice-Hall (1972)Google Scholar
  3. 3.
    Charras, C., Lecroq, T.: Handbook of exact string matching algorithms. Kings College Publications (2004)Google Scholar
  4. 4.
    Chase, D.R.: An improvement to bottom-up tree pattern matching. In: POPL, pp. 168–177. ACM Press (1987)Google Scholar
  5. 5.
    Cleophas, L.: Forest FIRE and FIRE wood: tools for tree automata and tree algorithms. In: Piskorski, J., Watson, B.W., Yli-Jyrä, A. (eds.) FSMNLP. Frontiers in Artificial Intelligence and Applications, vol. 19, pp. 191–198. IOS Press (2008)Google Scholar
  6. 6.
    Cleophas, L.: Tree Algorithms: Two Taxonomies and a Toolkit. Ph.D. thesis, Department of Mathematics and Computer Science, Eindhoven University of Technology (April 2008)Google Scholar
  7. 7.
    Cole, R., Hariharan, R., Indyk, P.: Tree pattern matching and subset matching in deterministic o(\(n log^3 n\)) time. In: Proceedings of the 10th ACM-SIAM Symposium on Discrete Algorithms, pp. 245–254 (1999)Google Scholar
  8. 8.
    Comon, H., Dauchet, M., Gilleron, R., Jacquemard, F., Lugiez, D., Tison, S., Tommasi, M.: Tree automata: Techniques and applications (2007). (release October 12, 2007)
  9. 9.
    Crochemore, M.A., Rytter, W.: Jewels of Stringology. World Scientific Publishing Company (2003)Google Scholar
  10. 10.
    Faro, S., Lecroq, T.: The exact online string matching problem: A review of the most recent results. ACM Comput. Surv. 45(2), 13 (2013)CrossRefGoogle Scholar
  11. 11.
    Flouri, T., Janoušek, J., Melichar, B., Iliopoulos, C.S., Pissis, S.P.: Tree template matching in ranked ordered trees by pushdown automata. In: Bouchou-Markhoff, B., Caron, P., Champarnaud, J.-M., Maurel, D. (eds.) CIAA 2011. LNCS, vol. 6807, pp. 273–281. Springer, Heidelberg (2011) CrossRefGoogle Scholar
  12. 12.
    Gécseg, F., Steinby, M.: Tree languages. In: Handbook of Formal Languages, vol. 3, pp. 1–68. Springer (1997)Google Scholar
  13. 13.
    Hoffmann, C.M., O’Donnell, M.J.: Pattern matching in trees. Journal of the ACM 29(1), 68–95 (1982)CrossRefzbMATHMathSciNetGoogle Scholar
  14. 14.
    Horspool, R.N.: Practical fast searching in strings. Software Practice and Experience 10(6), 501–506 (1980)CrossRefGoogle Scholar
  15. 15.
    Lang, H.W., Schimmler, M., Schmeck, H.: Matching tree patterns sublinear on the average. Christian-Albrechts-Universität, Tech. rep. (1980)Google Scholar
  16. 16.
    Smyth, W.F.: Computing Patterns in Strings. Addison-Wesley-Pearson Education Limited (2003)Google Scholar
  17. 17.
    Strolenberg, R.: ForestFIRE & FIREWood, A Toolkit & GUI for Tree Algorithms. Master’s thesis, Department of Mathematics and Computer Science, Eindhoven University of Technology (June 2007).
  18. 18.
    Watson, B.W.: A boyer-moore (or watson-watson) type algorithm for regular tree pattern matching. In: Stringology, pp. 33–38 (1997)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  • Jan Trávníček
    • 1
    Email author
  • Jan Janoušek
    • 1
  • Bořivoj Melichar
    • 1
  • Loek Cleophas
    • 2
    • 3
  1. 1.Faculty of Information Technology, Department of Theoretical Computer ScienceCzech Technical University in PraguePragueCzech Republic
  2. 2.FASTAR Research Group, Department of Information ScienceStellenbosch UniversityStellenboschRepublic of South Africa
  3. 3.Natural and Formal Languages Research Group, Department of Computer ScienceUmeå UniversityUmeåSweden

Personalised recommendations