Re: divide & conquer algorithm to implement string matching
- From: Willem <willem@xxxxxxxx>
- Date: Wed, 30 May 2007 21:42:41 +0000 (UTC)
misterio wrote:
) Maybe I'm wrong,but to me it seems that if I consider the lenght of
) the pattern to search a constant this algorithm takes O(n) time to
) compute the solution,if the length of the pattern is varying,in the
) worst case (that should be if the lenght of the pattern is an half of
) the lenght of the main string)this algorithm could take O(n^2) time to
) compute the solution.Am I right?
Probably. If the length of the pattern is constant, then the most
straightforward iterative solution is also O(n).
What would be more interesting is the time complexity as a function of both
the string length and the pattern length. Say, if the string length is n,
and the pattern length is m. Then the most basic algo would be O(n*m).
I'm guessing the D&C algorithm would be O(n*m) also ?
P.S.: It would actually be more like O((n-m+1)*m) but I'm not sure how
big-oh notation works with multiple variables.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
.
- Follow-Ups:
- Re: divide & conquer algorithm to implement string matching
- From: misterio
- Re: divide & conquer algorithm to implement string matching
- References:
- divide & conquer algorithm to implement string matching
- From: misterio
- Re: divide & conquer algorithm to implement string matching
- From: Logan Shaw
- Re: divide & conquer algorithm to implement string matching
- From: misterio
- Re: divide & conquer algorithm to implement string matching
- From: misterio
- Re: divide & conquer algorithm to implement string matching
- From: misterio
- Re: divide & conquer algorithm to implement string matching
- From: misterio
- Re: divide & conquer algorithm to implement string matching
- From: misterio
- Re: divide & conquer algorithm to implement string matching
- From: misterio
- divide & conquer algorithm to implement string matching
- Prev by Date: Re: Web vs. Desktop based systems
- Next by Date: Re: divide & conquer algorithm to implement string matching
- Previous by thread: Re: divide & conquer algorithm to implement string matching
- Next by thread: Re: divide & conquer algorithm to implement string matching
- Index(es):
Relevant Pages
|