Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Longest common subsequence
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Reading out all LCSs === If choosing <math>x_i</math> and <math>y_j</math> would give an equally long result, read out both resulting subsequences. This is returned as a set by this function. Notice that this function is not polynomial, as it might branch in almost every step if the strings are similar. '''function''' backtrackAll(C[0..m,0..n], X[1..m], Y[1..n], i, j) '''if''' i = 0 '''or''' j = 0 '''return''' {""} '''if''' X[i] = Y[j] '''return''' {Z + X[i] '''for all''' Z '''in''' backtrackAll(C, X, Y, i-1, j-1)} R := {} '''if''' C[i,j-1] β₯ C[i-1,j] R := backtrackAll(C, X, Y, i, j-1) '''if''' C[i-1,j] β₯ C[i,j-1] R := R βͺ backtrackAll(C, X, Y, i-1, j) '''return''' R
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)