Click here to Skip to main content
15,912,932 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Skippums29-Aug-07 6:30
Skippums29-Aug-07 6:30 
AnswerRe: Substring Matching (Harder than it sounds) Pin
Luc Pattyn29-Aug-07 6:32
sitebuilderLuc Pattyn29-Aug-07 6:32 
AnswerRe: Substring Matching (Harder than it sounds) [modified] Pin
Skippums29-Aug-07 7:42
Skippums29-Aug-07 7:42 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Russell'29-Aug-07 8:06
Russell'29-Aug-07 8:06 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Skippums29-Aug-07 8:28
Skippums29-Aug-07 8:28 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Russell'29-Aug-07 9:02
Russell'29-Aug-07 9:02 
AnswerRe: Substring Matching (Harder than it sounds) Pin
PIEBALDconsult29-Aug-07 18:03
mvePIEBALDconsult29-Aug-07 18:03 
AnswerRe: Substring Matching (Harder than it sounds) Pin
Mark Churchill29-Aug-07 18:26
Mark Churchill29-Aug-07 18:26 
I get the feeling its going to end up On^2ish no matter how you code around it. How big are your strings?

Brute force without the ram overhead would be to scan index pointers thru A and B, looking ahead in A as you get matches in B and keeping the highest match. Then incrementing the A pointer to the next character etc.

Depending on what your text looks at you might be able to hack in some optimisations (like checking if A[ia]+longestmatchlength != B[ib]+longestmatchlength -> increment ib by longestmatchlength).

In fact that small optimisation could speed an individual scan of the B array up over time - possibly even flattening the On^2 back down to closer to On.

Mark Churchill
Director
Dunn & Churchill

AnswerRe: Substring Matching (Harder than it sounds) Pin
cp987629-Aug-07 23:55
cp987629-Aug-07 23:55 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Skippums30-Aug-07 4:04
Skippums30-Aug-07 4:04 
AnswerRe: Substring Matching (Harder than it sounds) Pin
Skippums4-Sep-07 11:23
Skippums4-Sep-07 11:23 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Luc Pattyn4-Sep-07 13:06
sitebuilderLuc Pattyn4-Sep-07 13:06 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Skippums4-Sep-07 13:26
Skippums4-Sep-07 13:26 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Luc Pattyn5-Sep-07 9:00
sitebuilderLuc Pattyn5-Sep-07 9:00 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Skippums5-Sep-07 10:46
Skippums5-Sep-07 10:46 
GeneralRe: Substring Matching (Harder than it sounds) Pin
Member 419459329-Mar-08 9:55
Member 419459329-Mar-08 9:55 
QuestionNeed some intelligent people... Pin
Paddy Boyd29-Aug-07 2:20
Paddy Boyd29-Aug-07 2:20 
AnswerRe: Need some intelligent people... Pin
Luc Pattyn29-Aug-07 2:56
sitebuilderLuc Pattyn29-Aug-07 2:56 
GeneralRe: Need some intelligent people... Pin
Paddy Boyd29-Aug-07 3:42
Paddy Boyd29-Aug-07 3:42 
GeneralRe: Need some intelligent people... Pin
Paddy Boyd29-Aug-07 3:55
Paddy Boyd29-Aug-07 3:55 
GeneralRe: Need some intelligent people... Pin
Luc Pattyn29-Aug-07 4:42
sitebuilderLuc Pattyn29-Aug-07 4:42 
GeneralRe: Need some intelligent people... Pin
Paddy Boyd29-Aug-07 4:44
Paddy Boyd29-Aug-07 4:44 
AnswerRe: Need some intelligent people... Pin
Russell'29-Aug-07 4:54
Russell'29-Aug-07 4:54 
AnswerRe: Need some intelligent people... Pin
cp987629-Aug-07 16:18
cp987629-Aug-07 16:18 
GeneralRe: Need some intelligent people... Pin
Luc Pattyn29-Aug-07 23:41
sitebuilderLuc Pattyn29-Aug-07 23:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.