Re: divide & conquer algorithm to implement string matching
- From: cri@xxxxxxxx (Richard Harter)
- Date: Tue, 29 May 2007 14:14:03 GMT
On 29 May 2007 05:27:12 -0700, misterio <giagimari@xxxxxxxxx> wrote:
I'm trying to find a divide & conquer algorithm to implement a string
matching program that can find occurrences of a string like "0110" in
a string like "01101011001100110110".Does anybody has any idea?
If I understand the requirements properly you could do it like this:
Let n be the length of the large string and k be the length of the small
string. Start at position (n-k)/2 and examine bits in turn until you find
one that matches the start of the small string. Call that position p.
Then the right hand partition starts at p and ends at n. The left hand
partition starts at 1 and ends at p+k-1. (Adjust indexing to taste.)
In your example 01101011001100110110 would be partitioned into
0110101100110 and 1100110110.
This problem illustrates a principle that often is not articulated, namely
that divide and conquer partitions may have a soft boundary between the
partitions.
.
- 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
- 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
|