Question: A sequence is a palindrome if it is the same by reading from either its forward or backward direction. For example abbcbba and abccba are

A sequence is a palindrome if it is the same by reading from either its forward or backward direction. For example abbcbba and abccba are palindromes. abdbaa is not a palindrome, but it can be decomposed into three palindromes a, bdb, aa, or two palindromes abdba, a. The latter is better than the former, since the number of decomposed palindromes is the minimum. Given a sequence A=a1a2an, the palindrome decomposition problem is to find the minimal number of decomposed palindromes for A. Let d(i,j) denote the minimal number of decomposed palindromes for aiai+1aj,1ijn. Furthermore, let p(i,j) be a function for deciding whether aiai+1aj,1in, is a palindrome or not; p(i,j) returns 1 if it is a palindrome, and returns 0 if it is not. Obviously, d(i,j)=1 and p(i,j)=1 if i=j. Based on p(), please design the dynamic programming formula for determining d(i,j) for any i,j. Note that you do not need to design p(), you can use p() directly as a function call
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
