Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 19th, 2004, 05:26 AM
rosypop rosypop is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 rosypop User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Looking for a string algorithm

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

Reply With Quote
  #2  
Old May 19th, 2004, 12:12 PM
dog135's Avatar
dog135 dog135 is offline
Doggie
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2003
Location: Seattle, WA
Posts: 751 dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level)dog135 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 38 m 25 sec
Reputation Power: 7
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
__________________
"Science is constructed of facts as a house is of stones. But a collection of facts is no more a science than a heap of stones is a house." - Henri Poincare

Last edited by dog135 : May 19th, 2004 at 12:14 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Looking for a string algorithm


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT