<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wcipeg.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Longest_palindromic_subsequence</id>
		<title>Longest palindromic subsequence - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wcipeg.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Longest_palindromic_subsequence"/>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;action=history"/>
		<updated>2026-05-01T11:32:33Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.25.2</generator>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=2244&amp;oldid=prev</id>
		<title>162.158.62.29: removing confusing statement from proof</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=2244&amp;oldid=prev"/>
				<updated>2022-05-03T01:10:05Z</updated>
		
		<summary type="html">&lt;p&gt;removing confusing statement from proof&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 01:10, 3 May 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L11&quot; &gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Theorem''': Returning all longest palindromic subsequences cannot be accomplished in worst-case polynomial time.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Theorem''': Returning all longest palindromic subsequences cannot be accomplished in worst-case polynomial time.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Proof'''&amp;lt;ref name=&amp;quot;schneider&amp;quot;&amp;gt;Jonathan T. Schneider (2010). Personal communication.&amp;lt;/ref&amp;gt;: Consider a string made up of &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; ones, followed by &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, and finally &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; ones. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;(Assume &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is a multiple of 4, although it does not really matter.) &lt;/del&gt;Any palindromic subsequence either does not contain any zeroes, in which case its length is only up to &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;, or it contains at least one zero. If it contains at least one zero, it must be of the form &amp;lt;math&amp;gt;1^a0^b1^c&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; must be equal. (This is because the middle of the palindrome must lie somewhere within the zeroes, otherwise there would be no zeroes on one side of it and at least one zero on the other side; but as long as the middle lies within the zeroes, there must be an equal number of ones on each side.) But &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; can only be up to &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt;, and likewise with &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;, so again the palindrome cannot be longer than &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt; characters. However, there are &amp;lt;math&amp;gt;\binom{N/2}{N/4}+1&amp;lt;/math&amp;gt; palindromic subsequences of length &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;; we can either take all the ones, or we can take all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; terminal ones, and &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; out of the &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; initial ones. Thus the output size is not polynomial in &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt;, and then neither can the algorithm be in the worst case. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Proof'''&amp;lt;ref name=&amp;quot;schneider&amp;quot;&amp;gt;Jonathan T. Schneider (2010). Personal communication.&amp;lt;/ref&amp;gt;: Consider a string made up of &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; ones, followed by &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, and finally &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; ones. Any palindromic subsequence either does not contain any zeroes, in which case its length is only up to &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;, or it contains at least one zero. If it contains at least one zero, it must be of the form &amp;lt;math&amp;gt;1^a0^b1^c&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; must be equal. (This is because the middle of the palindrome must lie somewhere within the zeroes, otherwise there would be no zeroes on one side of it and at least one zero on the other side; but as long as the middle lies within the zeroes, there must be an equal number of ones on each side.) But &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; can only be up to &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt;, and likewise with &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;, so again the palindrome cannot be longer than &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt; characters. However, there are &amp;lt;math&amp;gt;\binom{N/2}{N/4}+1&amp;lt;/math&amp;gt; palindromic subsequences of length &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;; we can either take all the ones, or we can take all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; terminal ones, and &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; out of the &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; initial ones. Thus the output size is not polynomial in &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt;, and then neither can the algorithm be in the worst case. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, this does not rule out the existence of a polynomial-time algorithm for the first two variations on the problem. We now present such an algorithm.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, this does not rule out the existence of a polynomial-time algorithm for the first two variations on the problem. We now present such an algorithm.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>162.158.62.29</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=2188&amp;oldid=prev</id>
		<title>108.162.219.202: Typo</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=2188&amp;oldid=prev"/>
				<updated>2020-01-07T07:10:42Z</updated>
		
		<summary type="html">&lt;p&gt;Typo&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 07:10, 7 January 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Distinguish|Longest palindromic substring}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Distinguish|Longest palindromic substring}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The '''longest palindromic subsequence''' (LPS) problem is the problem of finding the longest [[subsequence]] of a string (a subsequence is obtained by deleting some of the characters from a string without reordering the remaining characters) which is also a palindrome. In general, the longest palindromic subsequence is not unique. For example, the string '''alfalfa''' has four palindromic subsequences of length 5: '''alala''', '''afafa''', '''alfla''', and '''aflfa'''. However, it does not have any palindromic subsequences longer than five characters. Therefore all four are &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;considred &lt;/del&gt;longest palindromic subsequences of '''alfalfa'''.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The '''longest palindromic subsequence''' (LPS) problem is the problem of finding the longest [[subsequence]] of a string (a subsequence is obtained by deleting some of the characters from a string without reordering the remaining characters) which is also a palindrome. In general, the longest palindromic subsequence is not unique. For example, the string '''alfalfa''' has four palindromic subsequences of length 5: '''alala''', '''afafa''', '''alfla''', and '''aflfa'''. However, it does not have any palindromic subsequences longer than five characters. Therefore all four are &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;considered &lt;/ins&gt;longest palindromic subsequences of '''alfalfa'''.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Precise statement==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Precise statement==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>108.162.219.202</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1823&amp;oldid=prev</id>
		<title>Spundun: /* LCS-based approach */ six, not three LPSes</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1823&amp;oldid=prev"/>
				<updated>2014-09-27T03:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;LCS-based approach: &lt;/span&gt; six, not three LPSes&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 03:31, 27 September 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L19&quot; &gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The standard algorithm for computing a longest palindromic subsequence of a given string &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; involves first computing a [[longest common subsequence]] (LCS) of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; and its reverse &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;. Often, this gives a correct LPS right away. For example, the reader may verify that '''alala''', '''afafa''', '''aflfa''' and '''alfla''' are all LCSes of '''alfalfa''' and its reverse '''aflafla'''. However, this is not ''always'' the case; for example, '''afala''' and '''alafa''' are ''also'' LCSes of '''alfalfa''' and its reverse, yet neither is palindromic. While it is clear that any LPS of a string is an LCS of the string and its reverse, the converse is false.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The standard algorithm for computing a longest palindromic subsequence of a given string &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; involves first computing a [[longest common subsequence]] (LCS) of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; and its reverse &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;. Often, this gives a correct LPS right away. For example, the reader may verify that '''alala''', '''afafa''', '''aflfa''' and '''alfla''' are all LCSes of '''alfalfa''' and its reverse '''aflafla'''. However, this is not ''always'' the case; for example, '''afala''' and '''alafa''' are ''also'' LCSes of '''alfalfa''' and its reverse, yet neither is palindromic. While it is clear that any LPS of a string is an LCS of the string and its reverse, the converse is false.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, with a slight modification, this algorithm can be made to work. We will use the example string '''ABCDEBCA''', which has &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;three &lt;/del&gt;LPSes: '''ABCBA''', '''ABDBA''', &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;and &lt;/del&gt;'''ACDCA''' (and our objective is to find one of them). Suppose that we find an LCS which is not one of these, such as &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''ABDCA''':&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, with a slight modification, this algorithm can be made to work. We will use the example string '''ABCDEBCA''', which has &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;six &lt;/ins&gt;LPSes: '''ABCBA''', '''ABDBA''', &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''ABEBA''', &lt;/ins&gt;'''ACDCA&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''', '''ACECA''' and '''ACBCA&lt;/ins&gt;''' (and our objective is to find one of them). Suppose that we find an LCS which is not one of these, such as &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''ABDCA''':&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: '''AB'''C'''D'''EB'''CA'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: '''AB'''C'''D'''EB'''CA'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: '''A'''C'''B'''E'''DC'''B'''A'''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;: '''A'''C'''B'''E'''DC'''B'''A'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Spundun</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1822&amp;oldid=prev</id>
		<title>Spundun: /* LCS-based approach */ again four LPSes</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1822&amp;oldid=prev"/>
				<updated>2014-09-27T01:42:19Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;LCS-based approach: &lt;/span&gt; again four LPSes&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 01:42, 27 September 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L17&quot; &gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Algorithm==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Algorithm==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===LCS-based approach===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===LCS-based approach===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The standard algorithm for computing a longest palindromic subsequence of a given string &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; involves first computing a [[longest common subsequence]] (LCS) of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; and its reverse &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;. Often, this gives a correct LPS right away. For example, the reader may verify that '''alala''' &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;and &lt;/del&gt;'''afafa''' are &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;both &lt;/del&gt;LCSes of '''alfalfa''' and its reverse '''aflafla'''. However, this is not ''always'' the case; for example, '''afala''' and '''alafa''' are ''also'' LCSes of '''alfalfa''' and its reverse, yet neither is palindromic. While it is clear that any LPS of a string is an LCS of the string and its reverse, the converse is false.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The standard algorithm for computing a longest palindromic subsequence of a given string &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; involves first computing a [[longest common subsequence]] (LCS) of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; and its reverse &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;. Often, this gives a correct LPS right away. For example, the reader may verify that '''alala'''&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/ins&gt;'''afafa&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''', '''aflfa''' and '''alfla&lt;/ins&gt;''' are &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;all &lt;/ins&gt;LCSes of '''alfalfa''' and its reverse '''aflafla'''. However, this is not ''always'' the case; for example, '''afala''' and '''alafa''' are ''also'' LCSes of '''alfalfa''' and its reverse, yet neither is palindromic. While it is clear that any LPS of a string is an LCS of the string and its reverse, the converse is false.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, with a slight modification, this algorithm can be made to work. We will use the example string '''ABCDEBCA''', which has three LPSes: '''ABCBA''', '''ABDBA''', and '''ACDCA''' (and our objective is to find one of them). Suppose that we find an LCS which is not one of these, such as &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''ABDCA''':&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, with a slight modification, this algorithm can be made to work. We will use the example string '''ABCDEBCA''', which has three LPSes: '''ABCBA''', '''ABDBA''', and '''ACDCA''' (and our objective is to find one of them). Suppose that we find an LCS which is not one of these, such as &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''ABDCA''':&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Spundun</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1821&amp;oldid=prev</id>
		<title>Spundun: There are atleast 4 palidromic subsequences of length 5</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1821&amp;oldid=prev"/>
				<updated>2014-09-27T01:33:08Z</updated>
		
		<summary type="html">&lt;p&gt;There are atleast 4 palidromic subsequences of length 5&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 01:33, 27 September 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Distinguish|Longest palindromic substring}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Distinguish|Longest palindromic substring}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The '''longest palindromic subsequence''' (LPS) problem is the problem of finding the longest [[subsequence]] of a string (a subsequence is obtained by deleting some of the characters from a string without reordering the remaining characters) which is also a palindrome. In general, the longest palindromic subsequence is not unique. For example, the string '''alfalfa''' has &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;two &lt;/del&gt;palindromic subsequences of length 5: '''alala''' &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;and &lt;/del&gt;'''afafa'''. However, it does not have any palindromic subsequences longer than five characters. Therefore &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;'''alala''' and '''afafa''' &lt;/del&gt;are &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;both &lt;/del&gt;considred longest palindromic subsequences of '''alfalfa'''.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The '''longest palindromic subsequence''' (LPS) problem is the problem of finding the longest [[subsequence]] of a string (a subsequence is obtained by deleting some of the characters from a string without reordering the remaining characters) which is also a palindrome. In general, the longest palindromic subsequence is not unique. For example, the string '''alfalfa''' has &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;four &lt;/ins&gt;palindromic subsequences of length 5: '''alala'''&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, &lt;/ins&gt;'''afafa&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;''', '''alfla''', and '''aflfa&lt;/ins&gt;'''. However, it does not have any palindromic subsequences longer than five characters. Therefore &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;all four &lt;/ins&gt;are considred longest palindromic subsequences of '''alfalfa'''.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Precise statement==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Precise statement==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Spundun</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1753&amp;oldid=prev</id>
		<title>123.201.60.154: /* Direct solution */</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1753&amp;oldid=prev"/>
				<updated>2013-11-24T08:13:58Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Direct solution&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 08:13, 24 November 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L41&quot; &gt;Line 41:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;2 + f(i+1,j-1) &amp;amp; \text{if } j-i &amp;gt; 1 \text{ and } S_i = S_{j-1}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;2 + f(i+1,j-1) &amp;amp; \text{if } j-i &amp;gt; 1 \text{ and } S_i = S_{j-1}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\end{cases}&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;\end{cases}&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;To see calculate the cost, consider that the worst case occurs when every invocation to &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; requires a call on two different substrings. This can happen for invocations with strings of length &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;. So the total number of invocations is &amp;lt;math&amp;gt;2^{(n-1)}&amp;lt;/math&amp;gt;. &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;However, a lot of these invocations are repeats. If we store previously computed solutions, then the cost goes down. The above worst case happens when no matches are ever made, so this requires us to try out eliminating all strings that start at 0 and those that start at n-1, such that their combined length is &amp;lt;math&amp;gt;\leq n-1&amp;lt;/math&amp;gt;. This is just the number of ways to partition a given number into two non-negative integers, summed up over &amp;lt;math&amp;gt;1 ,..., n-1&amp;lt;/math&amp;gt;. The number of ways to partition &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; into two non-negative integers is &amp;lt;math&amp;gt;k + 1&amp;lt;/math&amp;gt;. Hence the overall cost is &amp;lt;math&amp;gt;O(n^2)&amp;lt;/math&amp;gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>123.201.60.154</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1657&amp;oldid=prev</id>
		<title>Brian at 23:39, 10 June 2012</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1657&amp;oldid=prev"/>
				<updated>2012-06-10T23:39:36Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 23:39, 10 June 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Distinguish|Longest palindromic substring}}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Distinguish|Longest palindromic substring}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The '''longest palindromic subsequence''' problem is the problem of finding the longest [[subsequence]] of a string (a subsequence is obtained by deleting some of the characters from a string without reordering the remaining characters) which is also a palindrome. In general, the longest palindromic subsequence is not unique. For example, the string '''alfalfa''' has two palindromic subsequences of length 5: '''alala''' and '''afafa'''. However, it does not have any palindromic subsequences longer than five characters. Therefore '''alala''' and '''afafa''' are both considred longest palindromic subsequences of '''alfalfa'''.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The '''longest palindromic subsequence''' &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(LPS) &lt;/ins&gt;problem is the problem of finding the longest [[subsequence]] of a string (a subsequence is obtained by deleting some of the characters from a string without reordering the remaining characters) which is also a palindrome. In general, the longest palindromic subsequence is not unique. For example, the string '''alfalfa''' has two palindromic subsequences of length 5: '''alala''' and '''afafa'''. However, it does not have any palindromic subsequences longer than five characters. Therefore '''alala''' and '''afafa''' are both considred longest palindromic subsequences of '''alfalfa'''.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Precise statement==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Precise statement==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L11&quot; &gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Theorem''': Returning all longest palindromic subsequences cannot be accomplished in worst-case polynomial time.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Theorem''': Returning all longest palindromic subsequences cannot be accomplished in worst-case polynomial time.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Proof'''&amp;lt;ref name=&amp;quot;schneider&amp;quot;&amp;gt;Jonathan T. Schneider (2010). Personal communication.&amp;lt;/ref&amp;gt;: Consider a string made up of &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; ones, followed by &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, and finally &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; ones. (Assume &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is a multiple of 4, although it does not really matter.) Any palindromic &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;substring &lt;/del&gt;either does not contain any zeroes, in which case its length is only up to &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;, or it contains at least one zero. If it contains at least one zero, it must be of the form &amp;lt;math&amp;gt;1^a0^b1^c&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; must be equal. (This is because the middle of the palindrome must lie somewhere within the zeroes, otherwise there would be no zeroes on one side of it and at least one zero on the other side; but as long as the middle lies within the zeroes, there must be an equal number of ones on each side.) But &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; can only be up to &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt;, and likewise with &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;, so again the palindrome cannot be longer than &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt; characters. However, there are &amp;lt;math&amp;gt;\binom{N/2}{N/4}+1&amp;lt;/math&amp;gt; palindromic &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;substrings &lt;/del&gt;of length &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;; we can either take all the ones, or we can take all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; terminal ones, and &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; out of the &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; initial ones. Thus the output size is not polynomial in &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt;, and then neither can the algorithm be in the worst case. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Proof'''&amp;lt;ref name=&amp;quot;schneider&amp;quot;&amp;gt;Jonathan T. Schneider (2010). Personal communication.&amp;lt;/ref&amp;gt;: Consider a string made up of &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; ones, followed by &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, and finally &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; ones. (Assume &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is a multiple of 4, although it does not really matter.) Any palindromic &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;subsequence &lt;/ins&gt;either does not contain any zeroes, in which case its length is only up to &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;, or it contains at least one zero. If it contains at least one zero, it must be of the form &amp;lt;math&amp;gt;1^a0^b1^c&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; must be equal. (This is because the middle of the palindrome must lie somewhere within the zeroes, otherwise there would be no zeroes on one side of it and at least one zero on the other side; but as long as the middle lies within the zeroes, there must be an equal number of ones on each side.) But &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; can only be up to &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt;, and likewise with &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;, so again the palindrome cannot be longer than &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt; characters. However, there are &amp;lt;math&amp;gt;\binom{N/2}{N/4}+1&amp;lt;/math&amp;gt; palindromic &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;subsequences &lt;/ins&gt;of length &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;; we can either take all the ones, or we can take all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; terminal ones, and &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; out of the &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; initial ones. Thus the output size is not polynomial in &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt;, and then neither can the algorithm be in the worst case. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, this does not rule out the existence of a polynomial-time algorithm for the first two variations on the problem. We now present such an algorithm.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, this does not rule out the existence of a polynomial-time algorithm for the first two variations on the problem. We now present such an algorithm.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Algorithm==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Algorithm==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;todo&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;===LCS-based approach===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;The standard algorithm for computing a longest palindromic subsequence of a given string &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; involves first computing a [[longest common subsequence]] (LCS) of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; and its reverse &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;. Often, this gives a correct LPS right away. For example, the reader may verify that '''alala''' and '''afafa''' are both LCSes of '''alfalfa''' and its reverse '''aflafla'''. However, this is not ''always'' the case; for example, '''afala''' and '''alafa''' are ''also'' LCSes of '''alfalfa''' and its reverse, yet neither is palindromic. While it is clear that any LPS of a string is an LCS of the string and its reverse, the converse is false.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;However, with a slight modification, this algorithm can be made to work. We will use the example string '''ABCDEBCA''', which has three LPSes: '''ABCBA''', '''ABDBA''', and '''ACDCA''' (and our objective is to find one of them). Suppose that we find an LCS which is not one of these, such as &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''ABDCA''':&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;: '''AB'''C'''D'''EB'''CA'''&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;: '''A'''C'''B'''E'''DC'''B'''A'''&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Now consider the central character &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''D''' of &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;. It splits &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; up into two parts, the part before and the part after: &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''ABC''' and &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''EBCA'''. We know that the first half of &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt; (&amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''AB''') is a subsequence of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, and that the second half of &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt; (&amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''CA''') is a subsequence of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Notice that &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt; is ''also'' split up into two parts: &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''ACBE'''&amp;amp;nbsp;=&amp;amp;nbsp;(&amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;)' and &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''CBA'''&amp;amp;nbsp;=&amp;amp;nbsp;(&amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;)'. Since &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt; is also a subsequence of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;', we see that &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; is a subsequence of &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;, and &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; is a subsequence of &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. But the fact that &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; is a subsequence of &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; implies (by reversing both strings) that (&amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;)'&amp;amp;nbsp;=&amp;amp;nbsp;'''BA''' is a subsequence of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;'''EBCA'''. Since &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; is a subsequence of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt; and (&amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;)' is a subsequence of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, we conclude that &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;(&amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;)'&amp;amp;nbsp;=&amp;amp;nbsp;'''ABDBA''' is a subsequence of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;&amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;&amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;&amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;. So we have obtained the desired result, a longest palindromic subsequence.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Extrapolating to the general case, we can always obtain a LPS by first taking the LCS of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt; and &amp;lt;var&amp;gt;S'&amp;lt;/var&amp;gt; and then &amp;quot;reflecting&amp;quot; the first half of the result onto the second half; that is, if &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt; has &amp;lt;var&amp;gt;k&amp;lt;/var&amp;gt; characters, then we replace the last &amp;amp;lfloor;&amp;lt;var&amp;gt;k&amp;lt;/var&amp;gt;/2&amp;amp;rfloor; characters of &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt; by the reverse of the first &amp;amp;lfloor;&amp;lt;var&amp;gt;k&amp;lt;/var&amp;gt;/2&amp;amp;rfloor; characters of &amp;lt;var&amp;gt;L&amp;lt;/var&amp;gt; to obtain a palindromic subsequence of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;. This is obviously a palindrome by the foregoing analysis; it is guaranteed to be a subsequence by the foregoing analysis; and it is guaranteed to be as long as possible because it is of the same length as any LCS, yet the length of an LCS is also the upper bound on the length of an LPS since every LPS must trivially be an LCS. The odd case is handled as above, and the even case very similarly (lacking only the central character &amp;lt;var&amp;gt;C&amp;lt;/var&amp;gt;).&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;The complexity of this algorithm is the same as the complexity of the LCS algorithm used. The textbook [[dynamic programming]] algorithm for LCS runs in &amp;lt;math&amp;gt;O(mn)&amp;lt;/math&amp;gt; time, so the time taken to find the LPS is &amp;lt;math&amp;gt;O(n^2)&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; is the length of &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;===Direct solution===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;There is also a &amp;quot;direct&amp;quot; &amp;lt;math&amp;gt;O(n^2)&amp;lt;/math&amp;gt; solution, also based on dynamic programming; it is very similar in principle to the approach based on the textbook LCS algorithm. We define &amp;lt;math&amp;gt;f(i,j)&amp;lt;/math&amp;gt; to be the length of the longest palindromic subsequence of the substring &amp;lt;var&amp;gt;S&amp;lt;/var&amp;gt;[&amp;lt;var&amp;gt;i&amp;lt;/var&amp;gt;,&amp;lt;var&amp;gt;j&amp;lt;/var&amp;gt;) (see [[half-open interval]]). Assuming indexing starting from zero, the objective is to compute &amp;lt;math&amp;gt;f(0,n)&amp;lt;/math&amp;gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;This is easy when the substring is empty, or when it consists of only a single character; the value of &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; will be 0 or 1, respectively. Otherwise,&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* when the substring's first and last characters are equal, add ''both'' of them to the longest palindromic subsequence of the characters in between to get a palindromic subsequence two characters longer;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* when they are unequal, then it's clearly not possible to use both of them to form a palindromic subsequence of the given substring, so the answer will be the same as if one of them were ignored.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Thus:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;:&amp;lt;math&amp;gt;f(i,j) = \begin{cases}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;0 &amp;amp; \text{if } j-i = 0 \\&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;1 &amp;amp; \text{if } j-i = 1 \\&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;\max(f(i+1,j),f(i,j-1)) &amp;amp; \text{if } j-i &amp;gt; 1 \text{ and } S_i \neq S_{j-1} \\&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;2 + f(i+1,j-1) &amp;amp; \text{if } j-i &amp;gt; 1 \text{ and } S_i = S_{j-1}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;\end{cases}&amp;lt;/math&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Brian</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1654&amp;oldid=prev</id>
		<title>Brian: anonymous comment was right: all the math in this article was wrong</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1654&amp;oldid=prev"/>
				<updated>2012-05-27T02:02:39Z</updated>
		
		<summary type="html">&lt;p&gt;anonymous comment was right: all the math in this article was wrong&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 02:02, 27 May 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L14&quot; &gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, this does not rule out the existence of a polynomial-time algorithm for the first two variations on the problem. We now present such an algorithm.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, this does not rule out the existence of a polynomial-time algorithm for the first two variations on the problem. We now present such an algorithm.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Theoretical background==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(Note: these Lemmas are &amp;quot;obvious&amp;quot; and their proofs will probably not help you intuitively understand how the algorithm works, so skip them if they are too heavy in mathematical notation for you.)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;''Lemma 1'': Any palindromic subsequence &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; of a string &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is a common subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and its reverse &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;''Proof'': Since &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is a subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;, its reverse &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; is a subsequence of &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt; But &amp;lt;math&amp;gt;s = s'&amp;lt;/math&amp;gt; since &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is a palindrome, so &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is a subsequence of &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;, and hence a common subsequence. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;''Lemma 2'': If there exists a common subsequence &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and its reverse &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;, then there exists a palindromic subsequence &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of length greater than or equal to &amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; which is a supersequence of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;''This lemma is false'': Consider the sequence &amp;quot;abacbab&amp;quot; and its reverse, which has 6 (longest) common subsequences of length 5; &amp;quot;ababa&amp;quot;, &amp;quot;babab&amp;quot;, &amp;quot;bacab&amp;quot;, &amp;quot;abcba&amp;quot;, &amp;quot;abcab&amp;quot; and &amp;quot;bacba&amp;quot;. The last two are obviously not palindromic, and there does not exist palindromic supersequences that are also subsequences of &amp;quot;abacbab&amp;quot;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;''Proof'': Let &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; denote the subsequence in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; denote the subsequence in &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; denote a supersequence of &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt;. Walk through the string &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; from left to right. that is, consider &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; goes from 0 to &amp;lt;math&amp;gt;N-1&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;i'&amp;lt;/math&amp;gt; denote &amp;lt;math&amp;gt;N-i-1&amp;lt;/math&amp;gt;, so that &amp;lt;math&amp;gt;S_i = S'_{i'}&amp;lt;/math&amp;gt; at all times. For each value of &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* If &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; then &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S'_{i'}&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* If &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; is not in &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; but &amp;lt;math&amp;gt;S'_{i'}&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt;, then, again, &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S'_{i'}&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Otherwise, &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; is not in &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S'_{i'}&amp;lt;/math&amp;gt; is not in &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;After this has completed, &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; is clearly a supersequence of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and a subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;, and likewise &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; is a supersequence of &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; and a subsequence of &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Furthermore, &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; are reverses of each other, because whenever a character &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; is added to the end of &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt;, the identical character &amp;lt;math&amp;gt;S'_{i'}&amp;lt;/math&amp;gt; is added to the beginning of &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt;, and ''vice versa''.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Now consider the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; character in &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt;. This is &amp;lt;math&amp;gt;S_j&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;j&amp;lt;/math&amp;gt; is the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; smallest index for which either &amp;lt;math&amp;gt;S_j&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;S'_{j'}&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt;. This means that &amp;lt;math&amp;gt;j'&amp;lt;/math&amp;gt; is the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; largest index for which either &amp;lt;math&amp;gt;S'_{j'}&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt;S_j&amp;lt;/math&amp;gt; is in &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, since &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt; are reverses of each other. Therefore, &amp;lt;math&amp;gt;S'_{j'}&amp;lt;/math&amp;gt; is the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; character in &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; (characters near the beginning of &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; originate from near the beginning of &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt; or the end of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;). But the &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;&amp;lt;sup&amp;gt;th&amp;lt;/sup&amp;gt; character in &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; is the &amp;lt;math&amp;gt;(n-i-1)&amp;lt;/math&amp;gt;&amp;lt;sup&amp;gt;st&amp;lt;/sup&amp;gt; character in &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt;, because &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; are reverses of each other. Therefore &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; is palindromic. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;'''Theorem''': Any [[longest common subsequence]] &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and its reverse &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt; is a longest palindromic subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;'''Proof''': Suppose &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is not palindromic. By Lemma 2, we know we can obtain a palindrome &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; that is a supersequence of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; and a subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;. This cannot be &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; itself since &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is not palindromic. So &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; must be longer than &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;. By Lemma 1, &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; is a common subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;. However, as &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; is longer than &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;, this contradicts &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; having been a longest common subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Likewise, suppose &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; is a longest common subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt; and palindromic but it is not a longest palindromic subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;. Then there again exists a longer palindromic subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt;, which gives a longer common subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;, a contradiction. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Algorithm==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Algorithm==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;A corollary of the Theorem is that a longest palindromic subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; can be found in &amp;lt;math&amp;gt;O(|S|^2)&amp;lt;/math&amp;gt; time simply by finding the longest common subsequence of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and its reverse.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;todo&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Note that there exist more efficient algorithms for finding longest common subsequences, which also give more efficient means of computing longest palindromic subsequences.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;==Shortest palindromic supersequence==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;It can also be shown that the shortest palindromic supersequence of a string &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; can be found by taking the [[Longest_common_subsequence#Shortest_common_supersequence|shortest common supersequence]] of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and its reverse. The proof is left as an exercise to the reader.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Brian</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1653&amp;oldid=prev</id>
		<title>80.167.121.74: /* Theoretical background */</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1653&amp;oldid=prev"/>
				<updated>2012-05-23T00:07:55Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Theoretical background&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 00:07, 23 May 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L23&quot; &gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;''Lemma 2'': If there exists a common subsequence &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and its reverse &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;, then there exists a palindromic subsequence &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of length greater than or equal to &amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; which is a supersequence of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;''Lemma 2'': If there exists a common subsequence &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; of length &amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and its reverse &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;, then there exists a palindromic subsequence &amp;lt;math&amp;gt;s^*&amp;lt;/math&amp;gt; of &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; of length greater than or equal to &amp;lt;math&amp;gt;L&amp;lt;/math&amp;gt; which is a supersequence of &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;''This lemma is false'': Consider the sequence &amp;quot;abacbab&amp;quot; and its reverse, which has 6 (longest) common subsequences of length 5; &amp;quot;ababa&amp;quot;, &amp;quot;babab&amp;quot;, &amp;quot;bacab&amp;quot;, &amp;quot;abcba&amp;quot;, &amp;quot;abcab&amp;quot; and &amp;quot;bacba&amp;quot;. The last two are obviously not palindromic, and there does not exist palindromic supersequences that are also subsequences of &amp;quot;abacbab&amp;quot;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;''Proof'': Let &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; denote the subsequence in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; denote the subsequence in &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; denote a supersequence of &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt;. Walk through the string &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; from left to right. that is, consider &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; goes from 0 to &amp;lt;math&amp;gt;N-1&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;i'&amp;lt;/math&amp;gt; denote &amp;lt;math&amp;gt;N-i-1&amp;lt;/math&amp;gt;, so that &amp;lt;math&amp;gt;S_i = S'_{i'}&amp;lt;/math&amp;gt; at all times. For each value of &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;''Proof'': Let &amp;lt;math&amp;gt;s&amp;lt;/math&amp;gt; denote the subsequence in &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt; denote the subsequence in &amp;lt;math&amp;gt;S'&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;{s^*}'&amp;lt;/math&amp;gt; denote a supersequence of &amp;lt;math&amp;gt;s'&amp;lt;/math&amp;gt;. Walk through the string &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; from left to right. that is, consider &amp;lt;math&amp;gt;S_i&amp;lt;/math&amp;gt; as &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt; goes from 0 to &amp;lt;math&amp;gt;N-1&amp;lt;/math&amp;gt;. Let &amp;lt;math&amp;gt;i'&amp;lt;/math&amp;gt; denote &amp;lt;math&amp;gt;N-i-1&amp;lt;/math&amp;gt;, so that &amp;lt;math&amp;gt;S_i = S'_{i'}&amp;lt;/math&amp;gt; at all times. For each value of &amp;lt;math&amp;gt;i&amp;lt;/math&amp;gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>80.167.121.74</name></author>	</entry>

	<entry>
		<id>https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1278&amp;oldid=prev</id>
		<title>Brian at 20:07, 3 April 2011</title>
		<link rel="alternate" type="text/html" href="https://wcipeg.com/wiki/index.php?title=Longest_palindromic_subsequence&amp;diff=1278&amp;oldid=prev"/>
				<updated>2011-04-03T20:07:05Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 20:07, 3 April 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L11&quot; &gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Theorem''': Returning all longest palindromic subsequences cannot be accomplished in worst-case polynomial time.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Theorem''': Returning all longest palindromic subsequences cannot be accomplished in worst-case polynomial time.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Proof'''&amp;lt;ref name=&amp;quot;schneider&amp;quot;/&amp;gt;: Consider a string made up of &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; ones, followed by &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, and finally &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; ones. (Assume &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is a multiple of 4, although it does not really matter.) Any palindromic substring either does not contain any zeroes, in which case its length is only up to &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;, or it contains at least one zero. If it contains at least one zero, it must be of the form &amp;lt;math&amp;gt;1^a0^b1^c&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; must be equal. (This is because the middle of the palindrome must lie somewhere within the zeroes, otherwise there would be no zeroes on one side of it and at least one zero on the other side; but as long as the middle lies within the zeroes, there must be an equal number of ones on each side.) But &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; can only be up to &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt;, and likewise with &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;, so again the palindrome cannot be longer than &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt; characters. However, there are &amp;lt;math&amp;gt;\binom{N/2}{N/4}+1&amp;lt;/math&amp;gt; palindromic substrings of length &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;; we can either take all the ones, or we can take all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; terminal ones, and &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; out of the &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; initial ones. Thus the output size is not polynomial in &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt;, and then neither can the algorithm be in the worst case. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;'''Proof'''&amp;lt;ref name=&amp;quot;schneider&amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;gt;Jonathan T. Schneider (2010). Personal communication.&amp;lt;&lt;/ins&gt;/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;ref&lt;/ins&gt;&amp;gt;: Consider a string made up of &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; ones, followed by &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, and finally &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; ones. (Assume &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is a multiple of 4, although it does not really matter.) Any palindromic substring either does not contain any zeroes, in which case its length is only up to &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;, or it contains at least one zero. If it contains at least one zero, it must be of the form &amp;lt;math&amp;gt;1^a0^b1^c&amp;lt;/math&amp;gt;, but &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; must be equal. (This is because the middle of the palindrome must lie somewhere within the zeroes, otherwise there would be no zeroes on one side of it and at least one zero on the other side; but as long as the middle lies within the zeroes, there must be an equal number of ones on each side.) But &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; can only be up to &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt;, and likewise with &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt;, so again the palindrome cannot be longer than &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt; characters. However, there are &amp;lt;math&amp;gt;\binom{N/2}{N/4}+1&amp;lt;/math&amp;gt; palindromic substrings of length &amp;lt;math&amp;gt;3N/4&amp;lt;/math&amp;gt;; we can either take all the ones, or we can take all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; zeroes, all &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; terminal ones, and &amp;lt;math&amp;gt;N/4&amp;lt;/math&amp;gt; out of the &amp;lt;math&amp;gt;N/2&amp;lt;/math&amp;gt; initial ones. Thus the output size is not polynomial in &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt;, and then neither can the algorithm be in the worst case. &amp;lt;math&amp;gt;_\blacksquare&amp;lt;/math&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, this does not rule out the existence of a polynomial-time algorithm for the first two variations on the problem. We now present such an algorithm.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;However, this does not rule out the existence of a polynomial-time algorithm for the first two variations on the problem. We now present such an algorithm.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;L49&quot; &gt;Line 49:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 49:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==References==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;references&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;ref name=&amp;quot;schneider&amp;quot;&amp;gt;Jonathan T. Schneider (2010). Personal communication.&amp;lt;/ref&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;references/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;references/&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Brian</name></author>	</entry>

	</feed>