<?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 for akalin.cx</title>
	<link>http://www.akalin.cx</link>
	<description>Musings on math, music, and computer science</description>
	<pubDate>Thu, 11 Mar 2010 22:10:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>Comment on Finding the longest palindromic substring in linear time 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>
	<item>
		<title>Comment on Finding the longest palindromic substring in linear time by andy</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-89594</link>
		<dc:creator>andy</dc:creator>
		<pubDate>Sun, 30 Aug 2009 20:42:03 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-89594</guid>
		<description>believe both the java and c++ versions the line (while loop):
while((i G.T. palLength)&#38;&#38;(str.charAt(i - palLength - 1) == str.charAt(i)))

needs to be changed with the if loop as in the original explanation
if ((i G.T. palLength)&#38;&#38;(str.charAt(i - palLength - 1) == str.charAt(i)))
{
   palLength += 2;
   i += 1;
   continue;
}

otherwise you end up getting an out of bounds exception for some test cases like 'aabbbb'

let me know if my interpretation of the java/c++ code is incorrect</description>
		<content:encoded><![CDATA[<p>believe both the java and c++ versions the line (while loop):<br />
while((i G.T. palLength)&amp;&amp;(str.charAt(i - palLength - 1) == str.charAt(i)))</p>
<p>needs to be changed with the if loop as in the original explanation<br />
if ((i G.T. palLength)&amp;&amp;(str.charAt(i - palLength - 1) == str.charAt(i)))<br />
{<br />
   palLength += 2;<br />
   i += 1;<br />
   continue;<br />
}</p>
<p>otherwise you end up getting an out of bounds exception for some test cases like &#8216;aabbbb&#8217;</p>
<p>let me know if my interpretation of the java/c++ code is incorrect</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Finding the longest palindromic substring in linear time by AnhDQ</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-86720</link>
		<dc:creator>AnhDQ</dc:creator>
		<pubDate>Sat, 23 May 2009 14:04:46 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-86720</guid>
		<description>very nice ;)</description>
		<content:encoded><![CDATA[<p>very nice ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Finding the longest palindromic substring in linear time by Mokhtar M. Khorshid</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-81115</link>
		<dc:creator>Mokhtar M. Khorshid</dc:creator>
		<pubDate>Sat, 15 Nov 2008 21:10:02 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-81115</guid>
		<description>Here is a C++ version converted from Artem's adaptation, it returns the length of the longest palindrome:

int fastFindPalindrome(string &#38;str)
{
	// Adaptation by Artem Grotov
	// Further adaptated by Mokhtar M. Khorshid

	int strLength = str.length();
	vector  vec;
	int i = 0;
	int palLength = 0;

	int Longest = 0;
	while(i  palLength) &#38;&#38; (str[i - palLength - 1] == str[i]) )
		{
			palLength += 2;
			i += 1;
		}
		//we expanded, push the length to the length array
		vec.push_back(palLength);
		Longest = max (Longest, palLength);
		//now loop through the prefix of the polygon to see the
		int s = vec.size() -2;
		int e = s - palLength;
		//see if we found a palindrome prefix sharing the left edge with the current palindrome
		bool found = false;
		for(int j = s; j &#62; e; --j)
		{
			int d = j -e -1;
			if(vec[j]==d)
			{
				palLength = d;
				found = true;
				break;
			}
			vec.push_back(min(d, vec[j]));
			Longest = max (Longest, min (d, vec[j]));
		}
		if(!found)
		{
			//polygon at i+1 should be a letter rather than a space between so palLength = 1 at least
			i+=1;
			palLength = 1;
		}
	}
	vec.push_back(palLength);
	Longest = max (Longest, palLength);
	//now we can fill in the loop if we want to get all the palindrome centers, but we don’t need it
	//now we can scan through the array to find the biggest value and deduct the string of the longest palindrome

	return Longest;
}</description>
		<content:encoded><![CDATA[<p>Here is a C++ version converted from Artem&#8217;s adaptation, it returns the length of the longest palindrome:</p>
<p>int fastFindPalindrome(string &amp;str)<br />
{<br />
	// Adaptation by Artem Grotov<br />
	// Further adaptated by Mokhtar M. Khorshid</p>
<p>	int strLength = str.length();<br />
	vector  vec;<br />
	int i = 0;<br />
	int palLength = 0;</p>
<p>	int Longest = 0;<br />
	while(i  palLength) &amp;&amp; (str[i - palLength - 1] == str[i]) )<br />
		{<br />
			palLength += 2;<br />
			i += 1;<br />
		}<br />
		//we expanded, push the length to the length array<br />
		vec.push_back(palLength);<br />
		Longest = max (Longest, palLength);<br />
		//now loop through the prefix of the polygon to see the<br />
		int s = vec.size() -2;<br />
		int e = s - palLength;<br />
		//see if we found a palindrome prefix sharing the left edge with the current palindrome<br />
		bool found = false;<br />
		for(int j = s; j &gt; e; &#8211;j)<br />
		{<br />
			int d = j -e -1;<br />
			if(vec[j]==d)<br />
			{<br />
				palLength = d;<br />
				found = true;<br />
				break;<br />
			}<br />
			vec.push_back(min(d, vec[j]));<br />
			Longest = max (Longest, min (d, vec[j]));<br />
		}<br />
		if(!found)<br />
		{<br />
			//polygon at i+1 should be a letter rather than a space between so palLength = 1 at least<br />
			i+=1;<br />
			palLength = 1;<br />
		}<br />
	}<br />
	vec.push_back(palLength);<br />
	Longest = max (Longest, palLength);<br />
	//now we can fill in the loop if we want to get all the palindrome centers, but we don’t need it<br />
	//now we can scan through the array to find the biggest value and deduct the string of the longest palindrome</p>
<p>	return Longest;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Finding the longest palindromic substring in linear time by john hui</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-76797</link>
		<dc:creator>john hui</dc:creator>
		<pubDate>Wed, 06 Aug 2008 20:50:32 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-76797</guid>
		<description>How is this solution linear time.

For each center, to find whether it is a palindrome, it take O(n) and it's possible we use each letter in string as center so there is n centers.

so the run-time is o(n^2)?

I know I am missing something in the run-time analysis.  Can you go into details on why the run-time is O(n)?</description>
		<content:encoded><![CDATA[<p>How is this solution linear time.</p>
<p>For each center, to find whether it is a palindrome, it take O(n) and it&#8217;s possible we use each letter in string as center so there is n centers.</p>
<p>so the run-time is o(n^2)?</p>
<p>I know I am missing something in the run-time analysis.  Can you go into details on why the run-time is O(n)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Finding the longest palindromic substring in linear time by raj</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-76684</link>
		<dc:creator>raj</dc:creator>
		<pubDate>Tue, 05 Aug 2008 17:37:50 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-76684</guid>
		<description>niceee</description>
		<content:encoded><![CDATA[<p>niceee</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Finding the longest palindromic substring in linear time by Artem Grotov</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-74754</link>
		<dc:creator>Artem Grotov</dc:creator>
		<pubDate>Mon, 07 Jul 2008 08:44:37 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-74754</guid>
		<description>A Java version
public static void fastFindPalindrome(String str)
	{
		//Adaptation by Artem Grotov
		int strLength = str.length();
		Vector vec = new Vector();
		int i = 0;
		int palLength = 0;
		while(i &#60; strLength)
		{
			//expand palindrome at curr center defined by i and palLength
			while((i palLength)&#38;&#38;(str.charAt(i - palLength - 1) == str.charAt(i)))
			{
				palLength += 2;
				i += 1;
			}
			//we expanded, push the length to the length array
			vec.add(new Integer(palLength));
			//now loop through the prefix of the polygon to see the 
			int s = vec.size() -2;
			int e = s - palLength;
			//see if we found a palindrome prefix sharing the left edge with the current palindrome
			boolean found = false;
			for(int j = s; j &#62; e; j--)
			{
				int d = j -e -1;
				//if(((Integer)vec.elementAt(j)).intValue()==d)
				if(((Integer)vec.elementAt(j)).intValue()==d)
				{
					palLength = d;
					found = true;
					break;
				}
				vec.add(new Integer(Math.min(d, ((Integer)vec.elementAt(j)).intValue())));
			}
			if(!found)
			{
				//polygon at i+1 should be a letter rather than a space between so palLength = 1 at least
				i+=1;
				palLength = 1;
			}
		}
		vec.add(new Integer(palLength));
		//now we can fill in the loop if we want to get all the palindrome centers, but we don't need it
		//now we can scan through the array to find the biggest value and deduct the string of the longest palindrome
	
	}</description>
		<content:encoded><![CDATA[<p>A Java version<br />
public static void fastFindPalindrome(String str)<br />
	{<br />
		//Adaptation by Artem Grotov<br />
		int strLength = str.length();<br />
		Vector vec = new Vector();<br />
		int i = 0;<br />
		int palLength = 0;<br />
		while(i &lt; strLength)<br />
		{<br />
			//expand palindrome at curr center defined by i and palLength<br />
			while((i palLength)&amp;&amp;(str.charAt(i - palLength - 1) == str.charAt(i)))<br />
			{<br />
				palLength += 2;<br />
				i += 1;<br />
			}<br />
			//we expanded, push the length to the length array<br />
			vec.add(new Integer(palLength));<br />
			//now loop through the prefix of the polygon to see the<br />
			int s = vec.size() -2;<br />
			int e = s - palLength;<br />
			//see if we found a palindrome prefix sharing the left edge with the current palindrome<br />
			boolean found = false;<br />
			for(int j = s; j &gt; e; j&#8211;)<br />
			{<br />
				int d = j -e -1;<br />
				//if(((Integer)vec.elementAt(j)).intValue()==d)<br />
				if(((Integer)vec.elementAt(j)).intValue()==d)<br />
				{<br />
					palLength = d;<br />
					found = true;<br />
					break;<br />
				}<br />
				vec.add(new Integer(Math.min(d, ((Integer)vec.elementAt(j)).intValue())));<br />
			}<br />
			if(!found)<br />
			{<br />
				//polygon at i+1 should be a letter rather than a space between so palLength = 1 at least<br />
				i+=1;<br />
				palLength = 1;<br />
			}<br />
		}<br />
		vec.add(new Integer(palLength));<br />
		//now we can fill in the loop if we want to get all the palindrome centers, but we don&#8217;t need it<br />
		//now we can scan through the array to find the biggest value and deduct the string of the longest palindrome</p>
<p>	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Finding the longest palindromic substring in linear time by Titus</title>
		<link>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-52168</link>
		<dc:creator>Titus</dc:creator>
		<pubDate>Sat, 02 Feb 2008 12:33:24 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/#comment-52168</guid>
		<description>Wow!! Great Job!
I've found Johan Jeuring's solution, and failed to figure out Haskell language... This article is just like a translation for me, thank you a lot!</description>
		<content:encoded><![CDATA[<p>Wow!! Great Job!<br />
I&#8217;ve found Johan Jeuring&#8217;s solution, and failed to figure out Haskell language&#8230; This article is just like a translation for me, thank you a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on At long last&#8230; by akalin</title>
		<link>http://www.akalin.cx/2007/11/21/at-long-last-the-kindle/#comment-38048</link>
		<dc:creator>akalin</dc:creator>
		<pubDate>Sun, 25 Nov 2007 10:27:17 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/21/at-long-last-the-kindle/#comment-38048</guid>
		<description>More on the software side. I think I tried the actual device only a few times even when I was at Amazon.

And I don’t even read 4chan. &gt;:(</description>
		<content:encoded><![CDATA[<p>More on the software side. I think I tried the actual device only a few times even when I was at Amazon.</p>
<p>And I don’t even read 4chan. >:(</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on At long last&#8230; by Jess Lee</title>
		<link>http://www.akalin.cx/2007/11/21/at-long-last-the-kindle/#comment-37737</link>
		<dc:creator>Jess Lee</dc:creator>
		<pubDate>Fri, 23 Nov 2007 09:15:08 +0000</pubDate>
		<guid>http://www.akalin.cx/2007/11/21/at-long-last-the-kindle/#comment-37737</guid>
		<description>Congrats on the Kindle launch!  Did you work on the hardware or the software side of things?  

I didn't know you had a blog.  I expected more 4chan-like somethingawfulness from you.</description>
		<content:encoded><![CDATA[<p>Congrats on the Kindle launch!  Did you work on the hardware or the software side of things?  </p>
<p>I didn&#8217;t know you had a blog.  I expected more 4chan-like somethingawfulness from you.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
