<?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: Interview Questions: Shuffling an Array</title>
	<atom:link href="http://20bits.com/articles/interview-questions-shuffling-an-array/feed/" rel="self" type="application/rss+xml" />
	<link>http://20bits.com/articles/interview-questions-shuffling-an-array/</link>
	<description>Driven by Data</description>
	<lastBuildDate>Wed, 28 Jul 2010 21:50:46 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: gman</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-4729</link>
		<dc:creator>gman</dc:creator>
		<pubDate>Fri, 20 Nov 2009 13:52:04 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-4729</guid>
		<description>I was asked this question in an interview. I gave the seemingly correct but subtly wrong solution. Good to know the correct solution.</description>
		<content:encoded><![CDATA[<p>I was asked this question in an interview. I gave the seemingly correct but subtly wrong solution. Good to know the correct solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: praveen</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-4426</link>
		<dc:creator>praveen</dc:creator>
		<pubDate>Tue, 16 Jun 2009 23:57:51 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-4426</guid>
		<description>hello buddy how are you dear i read your comment it&#039;s great i like it dear i learn alot of things from your comment i hope everyone likes your post dear thanx for this information&lt;br&gt;&lt;br&gt;&lt;br&gt;=========================&lt;br&gt;will smith&lt;br&gt;=========================&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.cvandinterviews.com&quot;rel=&quot;dofollow&quot; rel=&quot;nofollow&quot;&gt;interview questions&lt;/a&gt;-interview questions</description>
		<content:encoded><![CDATA[<p>hello buddy how are you dear i read your comment it&#39;s great i like it dear i learn alot of things from your comment i hope everyone likes your post dear thanx for this information</p>
<p>=========================<br />will smith<br />=========================</p>
<p><a href="http://www.cvandinterviews.com"rel="dofollow" rel="nofollow">interview questions</a>-interview questions</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hanna</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-3498</link>
		<dc:creator>Hanna</dc:creator>
		<pubDate>Tue, 26 Aug 2008 19:08:39 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-3498</guid>
		<description>Hi,
Great effort after reading this I really good very nice point how to shuffle array keep it up
and post more article also check &lt;a href=&quot;http://www.interviewmadeeasy.info/ruby&quot; rel=&quot;nofollow&quot;&gt;Pre Developer&lt;/a&gt;

Thanks</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Great effort after reading this I really good very nice point how to shuffle array keep it up<br />
and post more article also check <a href="http://www.interviewmadeeasy.info/ruby" rel="nofollow">Pre Developer</a></p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-1115</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Sat, 12 Apr 2008 14:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-1115</guid>
		<description>What if the source and destination are picked using a random number generator N times? Given that the generator is unifrom, aren&#039;t all permutations possible?</description>
		<content:encoded><![CDATA[<p>What if the source and destination are picked using a random number generator N times? Given that the generator is unifrom, aren&#8217;t all permutations possible?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phil</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-1090</link>
		<dc:creator>phil</dc:creator>
		<pubDate>Fri, 11 Apr 2008 08:35:19 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-1090</guid>
		<description>rue, see here: http://eigenclass.org/hiki.rb?sort_by+rand+is+biased</description>
		<content:encoded><![CDATA[<p>rue, see here: <a href="http://eigenclass.org/hiki.rb?sort_by+rand+is+biased" rel="nofollow">http://eigenclass.org/hiki.rb?sort_by+rand+is+biased</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-1088</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Fri, 11 Apr 2008 01:39:02 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-1088</guid>
		<description>rue,

That&#039;s not really true, though.  In fact, that &quot;solution&quot; violates multiple requirements of the problems.

One, it&#039;s not in-place.  Two, whether or not the distribution is uniform depends on the sorting algorithm that &lt;tt&gt;sort_by&lt;/tt&gt; uses.</description>
		<content:encoded><![CDATA[<p>rue,</p>
<p>That&#8217;s not really true, though.  In fact, that &#8220;solution&#8221; violates multiple requirements of the problems.</p>
<p>One, it&#8217;s not in-place.  Two, whether or not the distribution is uniform depends on the sorting algorithm that <tt>sort_by</tt> uses.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rue</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-1084</link>
		<dc:creator>rue</dc:creator>
		<pubDate>Thu, 10 Apr 2008 21:06:49 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-1084</guid>
		<description>Excellent note about the algorithm. 

However, since pragmatism trumps all, the &quot;right&quot; way to shuffle an Array in Ruby is this:
 
  class Array
    def shuffle!
      replace(array.sort_by { rand })
    end
  end

As a bonus, it is a language/core lib bug and not your fault if there is a problem with the distribution ;)</description>
		<content:encoded><![CDATA[<p>Excellent note about the algorithm. </p>
<p>However, since pragmatism trumps all, the &#8220;right&#8221; way to shuffle an Array in Ruby is this:</p>
<p>  class Array<br />
    def shuffle!<br />
      replace(array.sort_by { rand })<br />
    end<br />
  end</p>
<p>As a bonus, it is a language/core lib bug and not your fault if there is a problem with the distribution ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-1083</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Thu, 10 Apr 2008 17:00:27 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-1083</guid>
		<description>cc,

You&#039;re right about the first point, but not the second.  Both self.size and size work because we&#039;re inside the Array instance.</description>
		<content:encoded><![CDATA[<p>cc,</p>
<p>You&#8217;re right about the first point, but not the second.  Both self.size and size work because we&#8217;re inside the Array instance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cc</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-1077</link>
		<dc:creator>cc</dc:creator>
		<pubDate>Thu, 10 Apr 2008 10:15:53 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-1077</guid>
		<description>Note: - I could be wrong here but I think you&#039;re code example#1 has a typo, you define variable r and don&#039;t use it, and use variable k and don&#039;t define it

and shouldn&#039;t it be n= self.size in example#1 as well as example#2?</description>
		<content:encoded><![CDATA[<p>Note: &#8211; I could be wrong here but I think you&#8217;re code example#1 has a typo, you define variable r and don&#8217;t use it, and use variable k and don&#8217;t define it</p>
<p>and shouldn&#8217;t it be n= self.size in example#1 as well as example#2?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phil</title>
		<link>http://20bits.com/articles/interview-questions-shuffling-an-array/comment-page-1/#comment-1076</link>
		<dc:creator>phil</dc:creator>
		<pubDate>Thu, 10 Apr 2008 09:38:08 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=90#comment-1076</guid>
		<description>For yet another Ruby implementation of Array#shuffle see Random numbers in Ruby, http://snippets.dzone.com/posts/show/4697 

Nice post!</description>
		<content:encoded><![CDATA[<p>For yet another Ruby implementation of Array#shuffle see Random numbers in Ruby, <a href="http://snippets.dzone.com/posts/show/4697" rel="nofollow">http://snippets.dzone.com/posts/show/4697</a> </p>
<p>Nice post!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
