<?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: Quicksort killer</title>
	<atom:link href="http://igoro.com/archive/quicksort-killer/feed/" rel="self" type="application/rss+xml" />
	<link>http://igoro.com/archive/quicksort-killer/</link>
	<description>On programming, technology, and random things of interest</description>
	<lastBuildDate>Fri, 11 May 2012 19:47:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: Hemanth</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-41743</link>
		<dc:creator>Hemanth</dc:creator>
		<pubDate>Wed, 14 Mar 2012 14:38:51 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-41743</guid>
		<description>may i know how to get time complexity for a particular example using quick sort?for example we have to sort this these elements like 60,59,70,13,5,80,12,if we sort it using quick sort hw to find time complexity plz reply plzzz</description>
		<content:encoded><![CDATA[<p>may i know how to get time complexity for a particular example using quick sort?for example we have to sort this these elements like 60,59,70,13,5,80,12,if we sort it using quick sort hw to find time complexity plz reply plzzz</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Ostrovsky</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-23181</link>
		<dc:creator>Igor Ostrovsky</dc:creator>
		<pubDate>Sat, 08 Oct 2011 21:11:23 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-23181</guid>
		<description>rakesh: Quick sort is one of the popular sorting algorithms, soit is used all over the place. For example, whenever you sort files in a file manager (e.g., Windows Explorer) by date, the file manager could reasonably be using quick sort.

Jesse: Distributive partitioning sort seems like an interesting algorithm - I wasn&#039;t aware of it. When splitting on median, it seems that the algorithm is O(N logN) in the worst case. Without that splitting, a killer set would be pretty easy to build, especially if the keys are floating point numbers.

E.g.: (1e100, 1e98, 1e96 ... 1) would take O(N^2). On the other hand, this form of a &#039;killer set&#039; cannot be generalized very far, since doubles only go up to 1e300 or so.</description>
		<content:encoded><![CDATA[<p>rakesh: Quick sort is one of the popular sorting algorithms, soit is used all over the place. For example, whenever you sort files in a file manager (e.g., Windows Explorer) by date, the file manager could reasonably be using quick sort.</p>
<p>Jesse: Distributive partitioning sort seems like an interesting algorithm &#8211; I wasn&#8217;t aware of it. When splitting on median, it seems that the algorithm is O(N logN) in the worst case. Without that splitting, a killer set would be pretty easy to build, especially if the keys are floating point numbers.</p>
<p>E.g.: (1e100, 1e98, 1e96 &#8230; 1) would take O(N^2). On the other hand, this form of a &#8216;killer set&#8217; cannot be generalized very far, since doubles only go up to 1e300 or so.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse Chisholm</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-23170</link>
		<dc:creator>Jesse Chisholm</dc:creator>
		<pubDate>Sat, 08 Oct 2011 20:38:46 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-23170</guid>
		<description>Others have mentioned Heap Sort and Radix Sort as alternatives to Quick Sort.  The ultimate in the Heap-Radix direction is the &lt;a href=&quot;http://xlinux.nist.gov/dads/HTML/distributivePartitioningSort.html&quot; rel=&quot;nofollow&quot;&gt;Distributive Partition Sort&lt;/a&gt;
( note: the article&#039;s initial split on the median is not essential.  It comes from the originator&#039;s implementation; and reduces the likelihood of in trouble with non-uniform data.  The original did not recur all the way to step 1, but only to a simplified step 2 on each bucket with more than one items. )

Basically a Bucket Sort where the number of buckets is equal to the number of elements to be sorted.  The Bucket Selector function chooses the bucket based on the Key, Minimum, Maximum and number of elements.
Expected case: O(N); Worst case as defined: O(N * log N); Worst case with lazy code: O(N ^ 2)

As with Quick Sort, the lazy comparer/selector is the one prone to the worst case.
e.g., if the selector only looks at the first byte that is different across all keys, then it is easy to build a killer data set.  Such a lazy selector would be O(N ^ 2), separating out one record per pass.

You could think of it as a Radix Sort where the largest possible key is a single digit in the chosen Radix.

Sadly, it generally requires high constants, so you really need a large data set to make it worth the trouble.</description>
		<content:encoded><![CDATA[<p>Others have mentioned Heap Sort and Radix Sort as alternatives to Quick Sort.  The ultimate in the Heap-Radix direction is the <a href="http://xlinux.nist.gov/dads/HTML/distributivePartitioningSort.html" rel="nofollow">Distributive Partition Sort</a><br />
( note: the article&#8217;s initial split on the median is not essential.  It comes from the originator&#8217;s implementation; and reduces the likelihood of in trouble with non-uniform data.  The original did not recur all the way to step 1, but only to a simplified step 2 on each bucket with more than one items. )</p>
<p>Basically a Bucket Sort where the number of buckets is equal to the number of elements to be sorted.  The Bucket Selector function chooses the bucket based on the Key, Minimum, Maximum and number of elements.<br />
Expected case: O(N); Worst case as defined: O(N * log N); Worst case with lazy code: O(N ^ 2)</p>
<p>As with Quick Sort, the lazy comparer/selector is the one prone to the worst case.<br />
e.g., if the selector only looks at the first byte that is different across all keys, then it is easy to build a killer data set.  Such a lazy selector would be O(N ^ 2), separating out one record per pass.</p>
<p>You could think of it as a Radix Sort where the largest possible key is a single digit in the chosen Radix.</p>
<p>Sadly, it generally requires high constants, so you really need a large data set to make it worth the trouble.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rakesh</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-22717</link>
		<dc:creator>rakesh</dc:creator>
		<pubDate>Thu, 06 Oct 2011 14:04:35 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-22717</guid>
		<description>can you please give me an example of any industrial field,educational field or any field which uses quick sort’s algorithm to get some output.</description>
		<content:encoded><![CDATA[<p>can you please give me an example of any industrial field,educational field or any field which uses quick sort’s algorithm to get some output.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anil</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-1798</link>
		<dc:creator>Anil</dc:creator>
		<pubDate>Thu, 02 Dec 2010 05:37:48 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-1798</guid>
		<description>Got you. Sorry for the confusion.</description>
		<content:encoded><![CDATA[<p>Got you. Sorry for the confusion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Ostrovsky</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-1795</link>
		<dc:creator>Igor Ostrovsky</dc:creator>
		<pubDate>Thu, 02 Dec 2010 05:23:17 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-1795</guid>
		<description>Hi Anil,

A typical median algorithm takes O(N) in the average case. But, as you say, the median algorithm will take O(N^2) for some bad cases.

However, there is a variant of the median algorithm that takes O(N) &lt;strong&gt;in the worst case&lt;/strong&gt;. That&#039;s the algorithm on the Wikipedia page that you linked to.

That algorithm has no &quot;bad case&quot; for the adversary to exploit.

Igor</description>
		<content:encoded><![CDATA[<p>Hi Anil,</p>
<p>A typical median algorithm takes O(N) in the average case. But, as you say, the median algorithm will take O(N^2) for some bad cases.</p>
<p>However, there is a variant of the median algorithm that takes O(N) <strong>in the worst case</strong>. That&#8217;s the algorithm on the Wikipedia page that you linked to.</p>
<p>That algorithm has no &#8220;bad case&#8221; for the adversary to exploit.</p>
<p>Igor</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anil</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-1794</link>
		<dc:creator>Anil</dc:creator>
		<pubDate>Thu, 02 Dec 2010 05:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-1794</guid>
		<description>Igor, I sincerely appreciate your awesome explanation. 

I got this point when I read your article for the first time though. I understand the role of finding median in this scenario. 

My only concern is that even finding median relies on the same &#039;Compare&#039; function (the adversarial Compare) since the order between these elements is defined only by that function and uses the same partitioning technique as quicksort. 

Now, don&#039;t you think the median finding algo will also get screwed up badly and take O(N^2) instead of O(N)?

Once it takes O(N^2), quicksort will also takes O(N^2 log N).

Some quicksorts use median-of-3 algo. But, that will not serve the purpose here. Am I missing something here? Thanks again. If I am being a pain, please ignore this comment :)</description>
		<content:encoded><![CDATA[<p>Igor, I sincerely appreciate your awesome explanation. </p>
<p>I got this point when I read your article for the first time though. I understand the role of finding median in this scenario. </p>
<p>My only concern is that even finding median relies on the same &#8216;Compare&#8217; function (the adversarial Compare) since the order between these elements is defined only by that function and uses the same partitioning technique as quicksort. </p>
<p>Now, don&#8217;t you think the median finding algo will also get screwed up badly and take O(N^2) instead of O(N)?</p>
<p>Once it takes O(N^2), quicksort will also takes O(N^2 log N).</p>
<p>Some quicksorts use median-of-3 algo. But, that will not serve the purpose here. Am I missing something here? Thanks again. If I am being a pain, please ignore this comment <img src='http://igoro.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Ostrovsky</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-1792</link>
		<dc:creator>Igor Ostrovsky</dc:creator>
		<pubDate>Thu, 02 Dec 2010 04:10:11 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-1792</guid>
		<description>Hi Anil,

Yes, my response was meant for you. And yes, I was referring to the linear selection algorithm that you linked to.

A typical quicksort implementation will pick the pivot in some &quot;naive&quot; way: pick the first element, or the middle element, or a pseudo-random element, etc. Such quicksort will get beaten by the adversary comparer.

However, you can actually pick the perfect pivot by computing the median of the array. Finding this pivot takes O(N) time. Using median find to select the pivot, the total running time of the quicksort is O(N logN) in the worst case - there are O(log N) recursion levels, and each level takes O(N) time.

I hope that is clear. By the way, the Wikipedia article you linked to also mentions the possibility of quicksort with worst case O(N log N): see the Important Notes section.

You might wonder why the median-based quick sort defeats the adversary. The reason is that the deterministic quicksort looks at O(N) elements before picking the pivot. And that is enough to guarantee that a good pivot will be chosen, even if the comparer acts as an adversary.</description>
		<content:encoded><![CDATA[<p>Hi Anil,</p>
<p>Yes, my response was meant for you. And yes, I was referring to the linear selection algorithm that you linked to.</p>
<p>A typical quicksort implementation will pick the pivot in some &#8220;naive&#8221; way: pick the first element, or the middle element, or a pseudo-random element, etc. Such quicksort will get beaten by the adversary comparer.</p>
<p>However, you can actually pick the perfect pivot by computing the median of the array. Finding this pivot takes O(N) time. Using median find to select the pivot, the total running time of the quicksort is O(N logN) in the worst case &#8211; there are O(log N) recursion levels, and each level takes O(N) time.</p>
<p>I hope that is clear. By the way, the Wikipedia article you linked to also mentions the possibility of quicksort with worst case O(N log N): see the Important Notes section.</p>
<p>You might wonder why the median-based quick sort defeats the adversary. The reason is that the deterministic quicksort looks at O(N) elements before picking the pivot. And that is enough to guarantee that a good pivot will be chosen, even if the comparer acts as an adversary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anil</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-1791</link>
		<dc:creator>Anil</dc:creator>
		<pubDate>Thu, 02 Dec 2010 03:04:56 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-1791</guid>
		<description>Hi Igor,

Was that a response towards me?

I fail to understand your claim of using a linear time median-finding algorithm to defeat the adversary. Could you please help me understand? Do you have this algorithm in mind for that approach?

http://en.wikipedia.org/wiki/Selection_algorithm#Linear_general_selection_algorithm_-_Median_of_Medians_algorithm</description>
		<content:encoded><![CDATA[<p>Hi Igor,</p>
<p>Was that a response towards me?</p>
<p>I fail to understand your claim of using a linear time median-finding algorithm to defeat the adversary. Could you please help me understand? Do you have this algorithm in mind for that approach?</p>
<p><a href="http://en.wikipedia.org/wiki/Selection_algorithm#Linear_general_selection_algorithm_-_Median_of_Medians_algorithm" rel="nofollow">http://en.wikipedia.org/wiki/S....._algorithm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Ostrovsky</title>
		<link>http://igoro.com/archive/quicksort-killer/comment-page-1/#comment-1790</link>
		<dc:creator>Igor Ostrovsky</dc:creator>
		<pubDate>Thu, 02 Dec 2010 00:20:50 +0000</pubDate>
		<guid isPermaLink="false">http://igoro.com/?p=33#comment-1790</guid>
		<description>If the quick sort uses the deterministic implementation, it is guaranteed to be O(N logN). For such algorithm, the adversary approach does not work.</description>
		<content:encoded><![CDATA[<p>If the quick sort uses the deterministic implementation, it is guaranteed to be O(N logN). For such algorithm, the adversary approach does not work.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

