Re: the lowest number of comparisons in string matching
- From: Michal Nazarewicz <mina86@xxxxxxx>
- Date: Tue, 26 Sep 2006 17:43:24 +0200
"laura" <laura.brandusan@xxxxxxxxx> writes:
The lowest number (theoretical) is m-n+1, but as far as I know no
algorithm has achieved this limit.
Michal Nazarewicz wrote:
How come m-n+1? The lowest number in the worst case (when the pattern
is located in the last place you are looking at) is m (the length of
the string).
sjdevnull@xxxxxxxxx writes:
(pattern string aka "needle" is length n, string to be searched aka
"haystack" is length m)
A needle of length n can't begin after position m-n in the haystack.
So then the lowest number of comparisons is m-n+1 if needle is not
found in haystack and m if it's there, correct?
--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>--<jid:mina86*jabber.org>--ooO--(_)--Ooo--
.
- Follow-Ups:
- Re: the lowest number of comparisons in string matching
- From: sjdevnull
- Re: the lowest number of comparisons in string matching
- References:
- the lowest number of comparisons in string matching
- From: laura
- Re: the lowest number of comparisons in string matching
- From: Michal Nazarewicz
- Re: the lowest number of comparisons in string matching
- From: sjdevnull
- the lowest number of comparisons in string matching
- Prev by Date: Re: print as a base 10 number
- Next by Date: Re: C or C++ streams question
- Previous by thread: Re: the lowest number of comparisons in string matching
- Next by thread: Re: the lowest number of comparisons in string matching
- Index(es):
Relevant Pages
|
|