Question: A palindrome is a non - empty string that reads the same forward and backward. Examples of palindromes are civic , racecar , and aibohphobia

A palindrome is a non-empty string that reads the same forward and backward. Examples of palindromes are civic,racecar, and aibohphobia(fear of palindromes). You are given a string as an array S[1,..., n] of length n. Your goal is to find the length of the longest palindromic subsequence of a string. Note that, by definition, a subsequence (unlike a subarray) can consist of non-consecutive elements. For example, for the string character, the answer is 5, which corresponds to the palindromic subsequence carac. For your DP algorithm, use the name MaxLength for the array (possibly multi-dimensional) which stores values of the subproblems.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!