<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Finding the longest palindromic substring in linear time</title>
	<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/</link>
	<description>Musings on math, music, and computer science</description>
	<pubDate>Wed, 08 Sep 2010 23:40:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: greme</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-95585</link>
		<dc:creator>greme</dc:creator>
		<pubDate>Sun, 18 Jul 2010 01:59:57 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-95585</guid>
		<description>hi,

great article. 

i however has some doubts why this is a O(n), let's take the example aaaaaaaaa, in this case, it is obvious that each a will have to be expended, according to the above algorithm, therefore it would be O(n^2). 

where did mess up?

thanks,</description>
		<content:encoded><![CDATA[<p>hi,</p>
<p>great article. </p>
<p>i however has some doubts why this is a O(n), let&#8217;s take the example aaaaaaaaa, in this case, it is obvious that each a will have to be expended, according to the above algorithm, therefore it would be O(n^2). </p>
<p>where did mess up?</p>
<p>thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jayant Jape</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-95143</link>
		<dc:creator>Jayant Jape</dc:creator>
		<pubDate>Tue, 22 Jun 2010 09:57:11 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-95143</guid>
		<description>I used your logic and trid to convert it to not to use array to save some space below is my version pl comment


        public static string GetLongestPelindrome()
        {

            string str = "dcfcdhihijkjihjfccccccccccabcdefggfedcba";
            int[] index = new int[str.Length];
            int[] length = new int[str.Length]; 
            char c;
            int currentindex = 0, i = 0, j = 0, bMaxindex = 0, bMaxLength = 0, sMaxindex = 0, sMaxLength = 0;

            if (str[0] == str[1])
            {
                currentindex = 0;
                bMaxLength = 2;
            }
            else 
            {
                currentindex = 1;
                bMaxLength = 1;
            }

            for (i = 0; i &#60; str.Length; i = j)
            {
                c = str[i];
                for (j = i + 1; j &#60; str.Length &#38;&#38; str[j] == c; j++) ;
                if (sMaxLength &#60; j - i)
                {
                    sMaxLength = j - i;
                    sMaxindex  = i;
                }
            }

            for (i = 2; i &#60; str.Length; i++)
            {
                if (i == 16) i = i;
                if (currentindex == (i - 1))
                {
                    if (str[i] == str[i - 2])
                    {
                        bMaxLength = 3;
                        bMaxindex = i - 2;
                        currentindex = i - 2;
                    }
                    else if (str[i] == str[i-1])
                    {
                        bMaxLength = 2;
                        bMaxindex = i - 2;
                        currentindex = i - 1;
                    }
                    else
                    {
                        currentindex = i;
                        bMaxLength = 1;
                        bMaxindex = i;
                    }
                }
                else
                {
                    if (currentindex - 1  sMaxLength)
                {
                    sMaxLength = bMaxLength;
                    sMaxindex = bMaxindex; 
                }

            }


            return (str.Substring(sMaxindex, sMaxLength)); 
        
        }</description>
		<content:encoded><![CDATA[<p>I used your logic and trid to convert it to not to use array to save some space below is my version pl comment</p>
<p>        public static string GetLongestPelindrome()<br />
        {</p>
<p>            string str = &#8220;dcfcdhihijkjihjfccccccccccabcdefggfedcba&#8221;;<br />
            int[] index = new int[str.Length];<br />
            int[] length = new int[str.Length];<br />
            char c;<br />
            int currentindex = 0, i = 0, j = 0, bMaxindex = 0, bMaxLength = 0, sMaxindex = 0, sMaxLength = 0;</p>
<p>            if (str[0] == str[1])<br />
            {<br />
                currentindex = 0;<br />
                bMaxLength = 2;<br />
            }<br />
            else<br />
            {<br />
                currentindex = 1;<br />
                bMaxLength = 1;<br />
            }</p>
<p>            for (i = 0; i &lt; str.Length; i = j)<br />
            {<br />
                c = str[i];<br />
                for (j = i + 1; j &lt; str.Length &amp;&amp; str[j] == c; j++) ;<br />
                if (sMaxLength &lt; j - i)<br />
                {<br />
                    sMaxLength = j - i;<br />
                    sMaxindex  = i;<br />
                }<br />
            }</p>
<p>            for (i = 2; i &lt; str.Length; i++)<br />
            {<br />
                if (i == 16) i = i;<br />
                if (currentindex == (i - 1))<br />
                {<br />
                    if (str[i] == str[i - 2])<br />
                    {<br />
                        bMaxLength = 3;<br />
                        bMaxindex = i - 2;<br />
                        currentindex = i - 2;<br />
                    }<br />
                    else if (str[i] == str[i-1])<br />
                    {<br />
                        bMaxLength = 2;<br />
                        bMaxindex = i - 2;<br />
                        currentindex = i - 1;<br />
                    }<br />
                    else<br />
                    {<br />
                        currentindex = i;<br />
                        bMaxLength = 1;<br />
                        bMaxindex = i;<br />
                    }<br />
                }<br />
                else<br />
                {<br />
                    if (currentindex - 1  sMaxLength)<br />
                {<br />
                    sMaxLength = bMaxLength;<br />
                    sMaxindex = bMaxindex;<br />
                }</p>
<p>            }</p>
<p>            return (str.Substring(sMaxindex, sMaxLength)); </p>
<p>        }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-95126</link>
		<dc:creator>Anand</dc:creator>
		<pubDate>Sun, 20 Jun 2010 15:49:47 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-95126</guid>
		<description>Can you guys please share the code for vec also. like vec.add and vec.size</description>
		<content:encoded><![CDATA[<p>Can you guys please share the code for vec also. like vec.add and vec.size</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zobayer</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-94171</link>
		<dc:creator>zobayer</dc:creator>
		<pubDate>Sat, 24 Apr 2010 12:02:49 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-94171</guid>
		<description>wow... amazing algorithm!!!</description>
		<content:encoded><![CDATA[<p>wow&#8230; amazing algorithm!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhishek</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-93768</link>
		<dc:creator>Abhishek</dc:creator>
		<pubDate>Wed, 24 Mar 2010 16:16:44 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-93768</guid>
		<description>Can you please explain or run your algorithm for a string which is not palindrome as a whole but a substring of this string is a palindrome. For example aabbbb (answer would be bbbb in this case).

Actually I am not able to understand the lengths array formation correctly or the array represents the list of longest palindrome lengths by center.

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Can you please explain or run your algorithm for a string which is not palindrome as a whole but a substring of this string is a palindrome. For example aabbbb (answer would be bbbb in this case).</p>
<p>Actually I am not able to understand the lengths array formation correctly or the array represents the list of longest palindrome lengths by center.</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tombstone</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-93074</link>
		<dc:creator>tombstone</dc:creator>
		<pubDate>Thu, 25 Feb 2010 05:51:11 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-93074</guid>
		<description>good work. awesome</description>
		<content:encoded><![CDATA[<p>good work. awesome</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohan Kumar</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-92769</link>
		<dc:creator>Mohan Kumar</dc:creator>
		<pubDate>Wed, 10 Feb 2010 07:07:26 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-92769</guid>
		<description>Could anybody explain the logic behind this....?</description>
		<content:encoded><![CDATA[<p>Could anybody explain the logic behind this&#8230;.?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-92358</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Thu, 28 Jan 2010 23:59:56 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-92358</guid>
		<description>Unless I'm missing something, I don't see how the running time is O(n).

Take for example the following input, "aaaaaaaaaa".  The algorithm above will expand the center on every iteration.</description>
		<content:encoded><![CDATA[<p>Unless I&#8217;m missing something, I don&#8217;t see how the running time is O(n).</p>
<p>Take for example the following input, &#8220;aaaaaaaaaa&#8221;.  The algorithm above will expand the center on every iteration.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thedemonhunter</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-90514</link>
		<dc:creator>thedemonhunter</dc:creator>
		<pubDate>Tue, 13 Oct 2009 21:29:22 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-90514</guid>
		<description>Well its a great post. I have run the code many times but its still not clicking. Could someone tell me what j and e denote or run through a complete example of the code.
Thanks a lot</description>
		<content:encoded><![CDATA[<p>Well its a great post. I have run the code many times but its still not clicking. Could someone tell me what j and e denote or run through a complete example of the code.<br />
Thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Argue</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-89917</link>
		<dc:creator>Argue</dc:creator>
		<pubDate>Tue, 15 Sep 2009 08:21:22 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-89917</guid>
		<description>I was searching for "largest palindromic substring" and who should pop up but you</description>
		<content:encoded><![CDATA[<p>I was searching for &#8220;largest palindromic substring&#8221; and who should pop up but you</p>
]]></content:encoded>
	</item>
</channel>
</rss>
