<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Palindromes</title>
	<atom:link href="http://blog.stchur.com/2008/06/14/palindromes/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.stchur.com/2008/06/14/palindromes/</link>
	<description>web / programming / javascript / css / html</description>
	<lastBuildDate>Tue, 29 Jun 2010 15:30:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ola</title>
		<link>http://blog.stchur.com/2008/06/14/palindromes/comment-page-1/#comment-1355</link>
		<dc:creator>Ola</dc:creator>
		<pubDate>Sat, 14 Jun 2008 21:37:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stchur.com/2008/06/14/palindromes/#comment-1355</guid>
		<description>I guess I should have looked at the actual times but this was what led me to believe it was faster...

&quot;As it turned out, this seemed to be faster than the other two methods.&quot;

And yea, what you discovered is actually what I expected.

The compare halves only has to go through half of the string while the traversal from both ends has to create an array, reverse it, change it back to a string and then compare the original string with the current string...</description>
		<content:encoded><![CDATA[<p>I guess I should have looked at the actual times but this was what led me to believe it was faster&#8230;</p>
<p>&#034;As it turned out, this seemed to be faster than the other two methods.&#034;</p>
<p>And yea, what you discovered is actually what I expected.</p>
<p>The compare halves only has to go through half of the string while the traversal from both ends has to create an array, reverse it, change it back to a string and then compare the original string with the current string&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sstchur</title>
		<link>http://blog.stchur.com/2008/06/14/palindromes/comment-page-1/#comment-1354</link>
		<dc:creator>sstchur</dc:creator>
		<pubDate>Sat, 14 Jun 2008 21:04:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stchur.com/2008/06/14/palindromes/#comment-1354</guid>
		<description>Ola:

&lt;p&gt;That&#039;s one of the things I find most interesting about Javascript.  Every time I think I know what is going to be fastest, I turn out to be wrong.&lt;/p&gt;

&lt;p&gt;I&#039;ve found that unless you &lt;em&gt;really&lt;/em&gt; know the internal working of the Javascript implementation in your particular browser (and I&#039;m sure there are some people that do, but I am not one of them), then there simply is no substitute for trying out your algorithm to see if it performs as you expected.&lt;/p&gt;

&lt;p&gt;To be clear though, the splitting, joining and reversing &lt;em&gt;wasn&#039;t&lt;/em&gt; faster in Javascript (did I somehow imply it was and not realize it?).  The compare halves version was fastest in Javascript.&lt;/p&gt;

&lt;p&gt;Personally, I would have expected the traversal from both ends to have been fastest.&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Ola:</p>
<p>That&#039;s one of the things I find most interesting about Javascript.  Every time I think I know what is going to be fastest, I turn out to be wrong.</p>
<p>I&#039;ve found that unless you <em>really</em> know the internal working of the Javascript implementation in your particular browser (and I&#039;m sure there are some people that do, but I am not one of them), then there simply is no substitute for trying out your algorithm to see if it performs as you expected.</p>
<p>To be clear though, the splitting, joining and reversing <em>wasn&#039;t</em> faster in Javascript (did I somehow imply it was and not realize it?).  The compare halves version was fastest in Javascript.</p>
<p>Personally, I would have expected the traversal from both ends to have been fastest.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ola</title>
		<link>http://blog.stchur.com/2008/06/14/palindromes/comment-page-1/#comment-1353</link>
		<dc:creator>Ola</dc:creator>
		<pubDate>Sat, 14 Jun 2008 20:41:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stchur.com/2008/06/14/palindromes/#comment-1353</guid>
		<description>I find it weird that all that splitting, reversing and joining are faster in JavaScript as opposed to the compare halves method. 

Probably because implementation of those is in C and we are going through the array in JavaScript?

Compare halves should be significantly faster in other languages.</description>
		<content:encoded><![CDATA[<p>I find it weird that all that splitting, reversing and joining are faster in JavaScript as opposed to the compare halves method. </p>
<p>Probably because implementation of those is in C and we are going through the array in JavaScript?</p>
<p>Compare halves should be significantly faster in other languages.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sstchur</title>
		<link>http://blog.stchur.com/2008/06/14/palindromes/comment-page-1/#comment-1352</link>
		<dc:creator>sstchur</dc:creator>
		<pubDate>Sat, 14 Jun 2008 19:38:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stchur.com/2008/06/14/palindromes/#comment-1352</guid>
		<description>&lt;p&gt;The code, as you have it written, does not actually work in Javascript (but that appears to be just due to a typo, so I can forgive that).&lt;/p&gt;

&lt;p&gt;But so far as I can tell, your solution is conceptually the same as the second solution I outlined, albeit you did it with a bit less code, but it does not turn out to be faster than the &quot;compare halves&quot; version (at least, not in Javascript/Firefox).&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>The code, as you have it written, does not actually work in Javascript (but that appears to be just due to a typo, so I can forgive that).</p>
<p>But so far as I can tell, your solution is conceptually the same as the second solution I outlined, albeit you did it with a bit less code, but it does not turn out to be faster than the &#034;compare halves&#034; version (at least, not in Javascript/Firefox).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luan Nguyen</title>
		<link>http://blog.stchur.com/2008/06/14/palindromes/comment-page-1/#comment-1351</link>
		<dc:creator>Luan Nguyen</dc:creator>
		<pubDate>Sat, 14 Jun 2008 19:27:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stchur.com/2008/06/14/palindromes/#comment-1351</guid>
		<description>Yeah, your code sucks :)

This is the fastest method:

function pal(s)
{
   var i, j,
   len = s.length,

   for (i = 0, j = len - 1; i &lt; j; i++, j--)
   {
      if (s.charAt(i) !== s.charAt(j)) return false;
   }
   return true;
}</description>
		<content:encoded><![CDATA[<p>Yeah, your code sucks <img src='http://blog.stchur.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This is the fastest method:</p>
<p>function pal(s)<br />
{<br />
   var i, j,<br />
   len = s.length,</p>
<p>   for (i = 0, j = len &#8211; 1; i &lt; j; i++, j&#8211;)<br />
   {<br />
      if (s.charAt(i) !== s.charAt(j)) return false;<br />
   }<br />
   return true;<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
