A linear time pattern matching algorithm between a string and a tree

  • Tatsuya Akutsu
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 684)


In this paper, we describe a linear time algorithm for testing whether or not there is a path of a tree T (¦V(T)¦= n) that coincides with a string s (¦s¦ = m). In the algorithm, O(n/m) vertices are selected from V(T) such that any path of length more than m −2 must contain at least one of the selected vertices. A search is performed using the selected vertices as ‘bases’. A suffix tree is used effectively in the algorithm. Although the size of the alphabet is assumed to be bounded by a constant in this paper, the algorithm can be applied to the case of unbounded alphabets by increasing the time complexity to O(n log n).


subtree subgraph isomorphism string matching suffix tree graph algorithms 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    A. Amir, G. Benson, and M. Farach. “Alphabet independent two dimensional pattern matching”. In Proceedings of ACM Symposium on Theory of Computing, pp. 59–68, 1992.Google Scholar
  2. 2.
    A. Apostolico, C. Iliopoulos, G. M. Landau, B. Schieber, and U. Vishkin. “Parallel construction of a suffix tree with applications”. Algorithmica, Vol. 3, pp. 347–365, 1988.Google Scholar
  3. 3.
    R. Boyer and S. Moore. “A fast string searching algorithm”. Communications of the ACM, Vol. 20, pp. 762–772, 1977.Google Scholar
  4. 4.
    M. J. Chung. “O(n 2.5) time algorithms for the subgraph homeomorphism on trees”. Journal of Algorithms, Vol. 8, pp. 106–112, 1987.Google Scholar
  5. 5.
    M. Dubiner, Z. Galil, and E Magen. “Faster tree pattern matching”. In Proceedings of IEEE Symposium on Foundations of Computer Science, pp. 145–150, 1990.Google Scholar
  6. 6.
    M. R. Garey and D. S. Johnson. “Computers and Intractability: A Guide to the Theory of NP-completeness”. Freeman, San Francisco, 1979.Google Scholar
  7. 7.
    D. E. Knuth, J. Morris, and V. Pratt. “Fast pattern matching in strings”. SIAM Journal on Computing, Vol. 6, pp. 323–350, 1977.Google Scholar
  8. 8.
    S. R. Kosaraju. “Efficient tree pattern matching”. In Proceedings of IEEE Symposium on Foundations of Computer Science, pp. 178–183, 1989.Google Scholar
  9. 9.
    G. M. Landau and U. Vishkin. “Fast parallel and serial approximate string matching”. Journal of Algorithms, Vol. 10, pp. 157–169, 1989.Google Scholar
  10. 10.
    A. Lingas. “Subgraph isomorphism for connected graphs of bounded valence and bounded separator is in NC”. In Proceedings of the 1988 International Conference on Parallel Processing, pp. 304–307, 1988.Google Scholar
  11. 11.
    E. M. McCreight. “A space-efficient suffix tree construction algorithm”. Journal of the ACM, Vol. 23, pp. 262–272, 1976.Google Scholar
  12. 12.
    S. W. Reyner. “An analysis of a good algorithm for the subtree problems”. SIAM Journal on Computing, Vol. 6, pp. 730–732, 1977.Google Scholar
  13. 13.
    R. E. Stobaugh. “Chemical substructure searching”. Journal of Chemical Information and Computer Sciences, Vol. 25, pp. 271–275, 1985.Google Scholar
  14. 14.
    E. H. Sussenguth. “A graph-theoretic algorithm for matching chemical structures”. Journal of Chemical Documentation, Vol. 5, pp. 36–43, 1965.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1993

Authors and Affiliations

  • Tatsuya Akutsu
    • 1
  1. 1.Mechanical Engineering LaboratoryIbarakiJapan

Personalised recommendations