0

I'm trying to think what is the difference between these two problems

Given a sequence S

1) Find the longest palindrome subsequence of S.

2) Find the longest subsequence of S whose reverse is also a subsequence of S. The two subsequences could be the same.
Original phrasing is :Find the longest subsequence S' of S, such that there is a subsequence that is the same as as S' and a subsequence that is the reverse of S'.

The DP formulations I derived for the two problems are the same.

Are they actually the same problems? I've been trying to think this way: Suppose the longest palindrome subsequence is longestP, then longestP itself is clearly a possible answer to 2).

Could there be a longer answer to 2)? Suppose there is one, called longerP, then the reverse of longerP is also a subsequence of S, call it reverseLongerP. Overlapped or not, a longer palindrome could be constructed from longerP and reverseLongerP. Thus contradictory to our assumption that longestP is the longest palindrome.

Could there be a shorter answer to 2)? I don't think so, since 2) asks us to find the longest subsequence of such kind, and longestP is already a possible answer, any subsequence that is shorter than longestP shouldn't be considered.

Above is my thinking to this problem, anything I'm missing?

My conclusion is that they are the same questions. However, I was asked to give a sequence that contains a string s which is not a palindrome and its reverse, as subsequences, while this sequence has no palindromes that are longer than s. I don’t think it’s possible.

My thinking is that, suppose such a sequence exists, then s and its reverse could form a palindrome with length of length_of_s + length_of_reverse_s - length_of_overlap, so the min length of this palindrome would be length_of_s. But in that case, length_of_overlap equals to length_of_s, so s and its reverse must be the same, s must be a palindrome, which would violate the s cannot be a palindrome restriction.

HM9527
  • 111
  • 1
  • 1
  • 5

1 Answers1

0

Okay I got where I was wrong. It's not guaranteed that s and reverse_of_s could form a palindrome. It's really easy to see this but I've been stuck in my wrong assumption. 4 3 1 2 3 4 2 1 is a good example.

HM9527
  • 111
  • 1
  • 1
  • 5