Talk:Algorithm Implementation/Strings/Longest common substring

Subsequence?
This looks like an implementation of longest common subsequence, not longest common substring.
 * It is using dynamic programming, which is used to locate the longest common subsequence. In fact, it is nearly identical to the Wagner-Fischer algorithm, which is commonly used for the subsequence problem.  However, each cell only increments from the cell to the left.  Therefore, it avoids gaps and ensures only a substring is located.  It would be very easy to alter this to find a longest common subsequence along with either a global or local alignment (and toss in Levenshtein distance while you are at it). Kainaw (talk) 13:02, 28 September 2010 (UTC)

Javascript problem
It looks as though the JavaScript here is dysfunctional. See http://granite.sru.edu/~ddailey/maxSubstring.htm for a rework of the code done by David Dwornick based on the C++ code shown on the same page. David.daileyatsrudotedu (discuss • contribs) 13:18, 27 March 2012 (UTC)

Can you improve the algorithm by "quitting"?
If I've found a match that's longer than the remaining string, I can quit looking, right?

Or would this extra check at each failed match hurt more than it helps?

(PS, "xrange" is just "range" in Python 3.)

--User6985 (discuss • contribs) 15:12, 12 February 2013 (UTC)

PHP alternative approach
I've come up with a shorter solution for PHP and would like to leave it here for someone to check if it's worth being published.

178.24.89.80 (discuss) 15:15, 3 September 2015 (UTC) Amica Noctis

VB.Net alternative approach
Please validate this before putting on main page in case some bug slipped under my notice. I couldn't find many test cases with known results to test against that were of any significant size.

This is focused on speed, memory usage is more than some other methods due to storage of pre-processing data. Probably performs best on large data sets with sparse matches for really small datasets brute force method may win since it doesn't have the pre-processing to do first. The idea behind this is it only thoroughly evaluates characters that exist in both sets(since all others couldn't be a match) and is capable of instantly jumping to the next match without having to evaluate all the possibilities between. it also has some code to reduce the number of results that are just sub strings of the longest one. it returns the O-based index of the result in both strings and the 1-based length. plenty of information to make the sub string if you need it. Swight1423 (discuss • contribs) 19:22, 28 January 2021 (UTC)