Perl Monk, Perl Meditation | |
PerlMonks |
Re: finding longest common substringby davido (Cardinal) |
on Nov 20, 2003 at 05:23 UTC ( [id://308504]=note: print w/replies, xml ) | Need Help?? |
I haven't seen this method posted yet. It doesn't get fancy with regexps, but is fairly clear and simple to understand. Like the rest, scalability is an issue.
One way to improve the algorithm to scale better may be to keep the arrays ordered in decending order of length so that you could just stop searching on the first match. That would require more overhead at "insertion" time, but much less at searching time.
Dave "If I had my life to live over again, I'd be a plumber." -- Albert Einstein
In Section
Seekers of Perl Wisdom
|
|