Friday, August 14, 2015

MJ [8] Longest Palindrome Subsequence

Question: 

Given a sequence of numbers, find the length of the longest palindrome subsequence. Eg., if nums = {1,2,2,0,1}, it should return 4 because the longest palindrome subsequence is {1,2,2,1}.


longestCS_rec
"Time complexity of the above naive recursive approach is O(2^n) in worst case and worst case happens when all characters of X and Y mismatch i.e., length of LCS is ."[2]

Ref
[1] http://www.mitbbs.com/article_t1/JobHunting/33026221_0_1.html
MJ
[2] http://www.geeksforgeeks.org/dynamic-programming-set-4-longest-common-subsequence/
Longest Common Subsequence. Very good explanation of DP.

No comments:

Post a Comment