473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Longest common substring

Hi...
could anyone help in finding the best algorithm for finding the longest common sub-string in two strings.....I'm familiar with the efficient algorithm to find the longest common sub-sequence and i tried modifying the same a bit to make it work for sub-string but i dont get the correct results...


Balanivash
Apr 10 '10 #1
3 3993
whodgson
542 512MB
strspn() returns the length of the longest substring of s1 that begins with s[0] and contains only characters found in s2. But I`m not sure that this is what you really want.
Apr 11 '10 #2
@whodgson
Dear Mr.Whodgson

strspn finds the length of the substring in s1 which has charcters from s2....but what i want is to find the substring which is common to both the strings....But thank you very much for your reply..

Balanivash
Apr 12 '10 #3
jkmyoung
2,057 Expert 2GB
Could you write out the most efficient method you have (in words, not code)? We might be able to see where you're slipping up with the implementation.

There are some code examples in wikipedia:
http://en.wikipedia.org/wiki/Longest...string_problem
Apr 12 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

47
by: Nick Mudge | last post by:
Hey everybody, let's make the longest newsgroup thread ever made. Find the posting "Any girls?" in this newsgroup and add a posting. The name of the thread is a great name for a programming...
14
by: Mudge | last post by:
This thread is hereby dubbed PHP Purpose, or PHPP. It has the following purposes: 1. To bring together PHPers and programmers around the world to become organized. 2. To dicuss purposes of...
12
by: Joerg Schuster | last post by:
Hello, The program given below returns the lines: a ab Is there a way to use python regular expressions such that the program would return the following lines?
9
by: john woo | last post by:
Hi Please see the following simple script: <TD align="Left" width="30%" > <select name="DEPARTMENT" SIZE ="1" style="width:200px;" onChange="Change()"> <option value="0"> &lt;ALL&gt...
2
by: Keith Chadwick | last post by:
XML <data> <option>this is test 1</option> <option>this is test 11</option> <option>this is test 111</option> <option>this is test 1111</option> <option>this is test 11111</option> </data>
1
by: Keith Chadwick | last post by:
XML <data> <option>this is test 1</option> <option>this is test 11</option> <option>this is test 111</option> <option>this is test 1111</option> <option>this is test 11111</option> </data>
1
by: almurph | last post by:
Hi everyone, I'm trying to find an impementation of the "longest common substring" problem in VB.NET. I'm having no joy online though. Anyone with it or know where it is? Would you like to...
32
by: Licheng Fang | last post by:
Basically, the problem is this: 'do' Python's NFA regexp engine trys only the first option, and happily rests on that. There's another example: 'oneself' The Python regular expression...
1
by: iElf | last post by:
can someone point out my error? cus this is printing out garbage and not the longest word... Program ( I underlined the loop Im trying to make to read and find the longest word) everything else...
9
by: C#_Help_needed | last post by:
I need help with the following question. THANKS :) Write a program in c# that takes in a directory as a command line parameter, and returns the longest repeated phrase in ALL text files in that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.