delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

Anybody know such an algorithm existing? Or some algorithms which can be refered? Any suggestion welcomed!
Thanks http://bbs.prog365.com/images/sites/smile.gif


Hello, all
I was looking for an algorithm to find continuous repeats in a string.  For an example,
Input:   MNMOPMOPKLABABABX
Output: MN{2: MOP}KL{3: AB}X
It is kind of like a compression algorithm.  But it only cares about the continuous repeats.
Both the string and the potential repeat cycle may be very long, so the algorithm should have a relatively high efficiency.
Anybody know such an algorithm existing? Or some algorithms which can be refered? Any suggestion welcomed!
Thanks
Author Hot threads

TOP

It's called RLE compression.  It's the same compression used in BMP files.  Shouldn't be too hard to find code for if you look around a bit.  I think you basically:
For each character, search forward for the same character.
Once you find the match, check the characters between to see if they match the characters following the matching character.
Repeat again if pattern continues.
Here's a snippet of code:
http://www.chilkatsoft.com/ChilkatDx/ck_rle.htm



Anybody know such an algorithm existing? Or some algorithms which can be refered? Any suggestion welcomed!
Thanks http://bbs.prog365.com/images/sites/smile.gif

TOP

Back Forum