Parameterized pattern matching: Algorithms and applications

被引:95
作者
Baker, BS
机构
[1] AT and T Bell Laboratories, Murray Hill, NJ 07974
关键词
D O I
10.1006/jcss.1996.0003
中图分类号
TP3 [计算技术、计算机技术];
学科分类号
0812 ;
摘要
The problem of finding sections of code that either are identical or are related by the systematic renaming of variables or constants can be modeled in terms of parameterized strings (p-strings) and parameterized matches (p-matches). P-strings are strings over two alphabets, one of which represents parameters. Two p-strings are a parameterized match (p-match) if one p-string is obtained by renaming the parameters of the other by a one-to-one function. In this paper, we investigate parameterized pattern matching via parameterized suffix trees (p-suffix trees). We give two algorithms for constructing p-suffix trees: one (eager) that runs in linear time for fixed alphabets, and another that uses auxiliary data structures and runs in O(n log(n)) time for Variable alphabets, where n is input length. We show that using a p-suffix tree for a pattern p-string P, it is possible to search for all p-matches of P within a text p-string Tin space linear in \P\ and time linear in \T\ for fixed alphabets, or O(\T\ log(min( \P\, sigma)) time and O(\P\) space for variable alphabets, where sigma is the sum of the alphabet sizes. The simpler p-suffix tree construction algorithm eager has been implemented, and experiments show it to be practical. Since it runs faster than predicted by the above worst-case bound, we reanalyze the algorithm and show that eager runs in time O(min(t\S\ + m(t, S) \ t>0) log sigma)), where for an input p-string S, m(t, S) is the number of maximal p-matches of length at least t that occur within S, and sigma is the sum of the alphabet sizes. Experiments with the author's program dup (B. Baker, in ''Comput. Sci. Statist.,'' Vol. 24, 1992) for finding all maximal p-matches within a p-string have found mt t, S) to be less than \S\ in practice unless t is small. (C) 1996 Academic Press, Inc.
引用
收藏
页码:28 / 42
页数:15
相关论文
共 19 条
[1]  
Aho A.V., 1974, The Design and Analysis of Computer Algorithms
[2]  
Aho A.V., 1990, HDB THEORETICAL COMP, P255, DOI [10.1016/B978-0-444-88071-0.50010-2, DOI 10.1016/B978-0-444-88071-0.50010-2]
[3]   EFFICIENT STRING MATCHING - AID TO BIBLIOGRAPHIC SEARCH [J].
AHO, AV ;
CORASICK, MJ .
COMMUNICATIONS OF THE ACM, 1975, 18 (06) :333-340
[4]   ALPHABET DEPENDENCE IN PARAMETERIZED MATCHING [J].
AMIR, A ;
FARACH, M ;
MUTHUKRISHNAN, S .
INFORMATION PROCESSING LETTERS, 1994, 49 (03) :111-115
[5]  
Baker B. S., 1993, Proceedings of the Twenty-Fifth Annual ACM Symposium on the Theory of Computing, P71, DOI 10.1145/167088.167115
[6]  
BAKER BS, 1992, COMPUTING SCIENCE AND STATISTICS : VOL 24, P49
[7]  
BAKER BS, 1995, PROCEEDINGS OF THE SIXTH ANNUAL ACM-SIAM SYMPOSIUM ON DISCRETE ALGORITHMS, P541
[8]  
BAKER BS, UNPUB PARAMETERIZED
[9]  
Chang W. I., 1990, Proceedings. 31st Annual Symposium on Foundations of Computer Science (Cat. No.90CH2925-6), P116, DOI 10.1109/FSCS.1990.89530
[10]  
CROCHEMORE M, 1987, LECT NOTES COMPUT SC, V249, P26