<?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: Computer Algorithms: Quicksort</title>
	<atom:link href="/2012/03/13/computer-algorithms-quicksort/feed/" rel="self" type="application/rss+xml" />
	<link>/2012/03/13/computer-algorithms-quicksort/</link>
	<description>on web development</description>
	<lastBuildDate>Fri, 26 Oct 2018 21:40:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>By: Scooby Doo</title>
		<link>/2012/03/13/computer-algorithms-quicksort/comment-page-1/#comment-18589</link>
		<dc:creator><![CDATA[Scooby Doo]]></dc:creator>
		<pubDate>Fri, 05 Apr 2013 10:06:12 +0000</pubDate>
		<guid isPermaLink="false">/?p=2899#comment-18589</guid>
		<description><![CDATA[Here is my recursive implementation, with no swaps between the elements of the array and the random-choosed pivot( only at the beginning ):

template
inline void quickSort( T* sort, const unsigned size )
{
	quickSortHelp( sort, 0, size - 1 );
}

template
void quickSortHelp( T* sort, const unsigned begin, const unsigned end )
{
	if ( begin &#060; end )
	{
		register unsigned L = begin;
		register unsigned R = end;

		unsigned index = rand() % ( end - begin + 1 ) + begin;

		register T pivot = sort[ index ];

		swappy( sort[ index ], sort[ end ] );

		while ( L &#060; R )
		{
			while ( sort[ L ] &#060; pivot &#038;&#038; L &#060; R )
				L++;

			if ( L  pivot &#038;&#038; L &#060; R )
				R--;

			if ( L &#060; R )
				sort[ L++ ] = sort[ R ];
		}

		sort[ L ] = pivot;

		if ( R &#060; 1 )
			R++;

		quickSortHelp( sort, begin, R - 1 );
		quickSortHelp( sort, L + 1, end );
	}
}]]></description>
		<content:encoded><![CDATA[<p>Here is my recursive implementation, with no swaps between the elements of the array and the random-choosed pivot( only at the beginning ):</p>
<p>template<br />
inline void quickSort( T* sort, const unsigned size )<br />
{<br />
	quickSortHelp( sort, 0, size &#8211; 1 );<br />
}</p>
<p>template<br />
void quickSortHelp( T* sort, const unsigned begin, const unsigned end )<br />
{<br />
	if ( begin &lt; end )<br />
	{<br />
		register unsigned L = begin;<br />
		register unsigned R = end;</p>
<p>		unsigned index = rand() % ( end &#8211; begin + 1 ) + begin;</p>
<p>		register T pivot = sort[ index ];</p>
<p>		swappy( sort[ index ], sort[ end ] );</p>
<p>		while ( L &lt; R )<br />
		{<br />
			while ( sort[ L ] &lt; pivot &amp;&amp; L &lt; R )<br />
				L++;</p>
<p>			if ( L  pivot &amp;&amp; L &lt; R )<br />
				R&#8211;;</p>
<p>			if ( L &lt; R )<br />
				sort[ L++ ] = sort[ R ];<br />
		}</p>
<p>		sort[ L ] = pivot;</p>
<p>		if ( R &lt; 1 )<br />
			R++;</p>
<p>		quickSortHelp( sort, begin, R &#8211; 1 );<br />
		quickSortHelp( sort, L + 1, end );<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scooby Doo</title>
		<link>/2012/03/13/computer-algorithms-quicksort/comment-page-1/#comment-18588</link>
		<dc:creator><![CDATA[Scooby Doo]]></dc:creator>
		<pubDate>Fri, 05 Apr 2013 09:50:42 +0000</pubDate>
		<guid isPermaLink="false">/?p=2899#comment-18588</guid>
		<description><![CDATA[I have recently read a brillinat article: Optimized QuickSort http://alienryderflex.com/quicksort/

There is only the iteretive version, but the recursive one can be very easy implemented based on that.

It completely eliminates the need for two more arrays &quot;left&quot; and &quot;right&quot; each time the function calls itself and I belive it is much faster than any other implementation.]]></description>
		<content:encoded><![CDATA[<p>I have recently read a brillinat article: Optimized QuickSort <a href="http://alienryderflex.com/quicksort/" rel="nofollow">http://alienryderflex.com/quicksort/</a></p>
<p>There is only the iteretive version, but the recursive one can be very easy implemented based on that.</p>
<p>It completely eliminates the need for two more arrays &#8220;left&#8221; and &#8220;right&#8221; each time the function calls itself and I belive it is much faster than any other implementation.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
