My code works for Computing the length of the LCS but I apply the same code for Reading out an LCS on the following link,
http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
but some strings are missing. Could you tell me what I am missing?
Google Playground link : http://play.golang.org/p/qnIWQqzAf5
func Back(table [][]int, str1, str2 string, i, j int) string {
if i == 0 || j == 0 {
return ""
} else if str1[i] == str2[j] {
return Back(table, str1, str2, i-1, j-1) + string(str1[i])
} else {
if table[i][j-1] > table[i-1][j] {
return Back(table, str1, str2, i, j-1)
} else {
return Back(table, str1, str2, i-1, j)
}
}
}
Thanks in advance.