Abstract
In the string prefix-matching problem one is interested in finding the longest prefix of a pattern string of length m that occurs starting at each position of a text string of length n. This is a natural generalization of the string matching problem where only occurences of the whole pattern are sought. The Knuth-Morris-Pratt string matching algorithm can be easily adapted to solve the string prefix-matching problem without making additional comparisons. In this paper we study the exact complexity of the string prefix-matching problem in the deterministic sequential comparison model. Our bounds do not account for comparisons made in a pattern preprocessing step. The following results are presented: 1. (1) A family of linear-time string prefix-matching algorithms that make at most ⌊( (2m−1) m )n⌋ comparisons. 2. (2) A tight lower bound of ⌊(( 2m−1) m )n⌋ comparisons for any string prefix-matching algorithm that has to match the pattern ‘ ab m −1’. We also consider the special case when the pattern and the text strings are the same string and all comparisons are accounted. This problem, which we call the string self-prefix problem, is similar to the failure function that is computed in the pattern preprocessing of the Knut-Morris-Pratt string matching algorithm and used in several other comparison efficient algorithms. By using the lower bound for the string prefix-matching problem we are able to show: 3. (3) A lower bound of 2m−⌊2 m ⌋ comparisons for the self-prefix problem.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.