A palindrome is a nonempty string over some alphabet that reads the same forward
ID: 3774338 • Letter: A
Question
A palindrome is a nonempty string over some alphabet that reads the same forward and backward. Examples of palindromes are all strings of length 1, civic, racecar, abba,… Give a DP algorithm to find the length of the longest palindrome that is a subsequence of a given input string. Write a program to solve this problem. Examples: Given the input “character”, your algorithm should return 5 for “carac”. Given the input “TTATGTGAT”, your algorithm should return 7 for “TATGTAT”. Note that TTATT is a palindromic subsequence but is not the longest. IN C#
Explanation / Answer
c[i, i+j] = max( c[i+1, i+j] , c[i, i+j-1] )compute-lps(s, n):
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.