Parameterized pattern matching : Algorithms and applications
1996
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|, σ)) time and O(|P|) space for variable alphabets, where σ 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 σ)), 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 σ is the sum of the alphabet sizes. Experiments with the author's program dup (8. Baker, in Comput. Sci. Statist., Vol. 24, 1992) for finding all maximal p-matches within a p-string have found m(t, S) to be less than |S| in practice unless t is small.
Keywords:
- Correction
- Cite
- Save
- Machine Reading By IdeaReader
0
References
9
Citations
NaN
KQI