<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Two Sub-Quadratic Sorts</title>
	<atom:link href="http://programmingpraxis.com/2009/10/30/two-sub-quadratic-sorts/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/10/30/two-sub-quadratic-sorts/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Sat, 11 Feb 2012 09:48:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Vikas Tandi</title>
		<link>http://programmingpraxis.com/2009/10/30/two-sub-quadratic-sorts/#comment-2940</link>
		<dc:creator><![CDATA[Vikas Tandi]]></dc:creator>
		<pubDate>Thu, 28 Apr 2011 04:28:01 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1567#comment-2940</guid>
		<description><![CDATA[shell sort implemented in c
[sourcecode lang=&quot;cpp&quot;]
#define NELEMS(x)	((sizeof(x))/(sizeof((x)[0])))

void shell_sort(int arr[], int n)
{
	int i, j, k;
	int gap;
	int sequence[] = {1750, 701, 301, 132, 57, 23, 10, 4, 1};
	int s;

	for(i = 0, s = NELEMS(sequence); i &lt; s; i++)
	{
		gap = sequence[i];

		for(j = gap; j &lt; n; j++)
		{
			int key;
			for(k = j - gap, key = arr[j]; (k &gt;= 0) &amp;&amp; (arr[k] &gt; key); k = k - gap)
				arr[k+gap] = arr[k];

			arr[k+gap] = key;
		}
	}
}
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>shell sort implemented in c</p>
<pre class="brush: cpp;">
#define NELEMS(x)	((sizeof(x))/(sizeof((x)[0])))

void shell_sort(int arr[], int n)
{
	int i, j, k;
	int gap;
	int sequence[] = {1750, 701, 301, 132, 57, 23, 10, 4, 1};
	int s;

	for(i = 0, s = NELEMS(sequence); i &lt; s; i++)
	{
		gap = sequence[i];

		for(j = gap; j &lt; n; j++)
		{
			int key;
			for(k = j - gap, key = arr[j]; (k &gt;= 0) &amp;&amp; (arr[k] &gt; key); k = k - gap)
				arr[k+gap] = arr[k];

			arr[k+gap] = key;
		}
	}
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2009/10/30/two-sub-quadratic-sorts/#comment-738</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Sat, 31 Oct 2009 11:48:39 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1567#comment-738</guid>
		<description><![CDATA[My Haskell solution (see http://bonsaicode.wordpress.com/2009/10/31/programming-praxis-two-sub-quadratic-sorts/ for a version with comments):

[sourcecode lang=&quot;css&quot;]
import Control.Monad
import Data.List
import Data.List.HT
import Data.Array.IO
import Data.Array.MArray

swap :: (MArray a e m, Ix i, Ord e) =&gt; i -&gt; i -&gt; a i e -&gt; m ()
swap i j a = do x &lt;- readArray a i
                y &lt;- readArray a j
                when (y &lt; x) $ writeArray a i y &gt;&gt; writeArray a j x

combSort :: Ord a =&gt; [a] -&gt; IO [a]
combSort [] = return []
combSort xs = comb (s-1) =&lt;&lt; newListArray (1, s) xs where
    comb :: Ord a =&gt; Int -&gt; IOArray Int a -&gt; IO [a]
    comb 0 a = getElems a
    comb n a = mapM_ (\i -&gt; swap i (i+n) a) [1..s-n] &gt;&gt; comb (n-1) a
    s = length xs

shellSort :: Ord a =&gt; [a] -&gt; IO [a]
shellSort [] = return []
shellSort xs = return $ shell (last . takeWhile (&lt; length xs) $
                               iterate (succ . (*3)) 1) xs where
    shell 1 = foldr insert []
    shell n = shell (div (n-1) 3) . concatMap (shell 1) . sliceHorizontal n
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My Haskell solution (see <a href="http://bonsaicode.wordpress.com/2009/10/31/programming-praxis-two-sub-quadratic-sorts/" rel="nofollow">http://bonsaicode.wordpress.com/2009/10/31/programming-praxis-two-sub-quadratic-sorts/</a> for a version with comments):</p>
<pre class="brush: css;">
import Control.Monad
import Data.List
import Data.List.HT
import Data.Array.IO
import Data.Array.MArray

swap :: (MArray a e m, Ix i, Ord e) =&gt; i -&gt; i -&gt; a i e -&gt; m ()
swap i j a = do x &lt;- readArray a i
                y &lt;- readArray a j
                when (y &lt; x) $ writeArray a i y &gt;&gt; writeArray a j x

combSort :: Ord a =&gt; [a] -&gt; IO [a]
combSort [] = return []
combSort xs = comb (s-1) =&lt;&lt; newListArray (1, s) xs where
    comb :: Ord a =&gt; Int -&gt; IOArray Int a -&gt; IO [a]
    comb 0 a = getElems a
    comb n a = mapM_ (\i -&gt; swap i (i+n) a) [1..s-n] &gt;&gt; comb (n-1) a
    s = length xs

shellSort :: Ord a =&gt; [a] -&gt; IO [a]
shellSort [] = return []
shellSort xs = return $ shell (last . takeWhile (&lt; length xs) $
                               iterate (succ . (*3)) 1) xs where
    shell 1 = foldr insert []
    shell n = shell (div (n-1) 3) . concatMap (shell 1) . sliceHorizontal n
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Two Sub-Quadratic Sorts &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2009/10/30/two-sub-quadratic-sorts/#comment-737</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Two Sub-Quadratic Sorts &#171; Bonsai Code]]></dc:creator>
		<pubDate>Sat, 31 Oct 2009 11:48:20 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1567#comment-737</guid>
		<description><![CDATA[[...] Praxis &#8211; Two Sub-Quadratic&#160;Sorts By Remco Niemeijer  In yesterday&#8217;s Programming Praxis problem we have to implement two sort algorithms. Let&#8217;s get [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Praxis &#8211; Two Sub-Quadratic&nbsp;Sorts By Remco Niemeijer  In yesterday&#8217;s Programming Praxis problem we have to implement two sort algorithms. Let&#8217;s get [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Posts about Programming from google blogs as of October 30, 2009 &#171; tryfly.com</title>
		<link>http://programmingpraxis.com/2009/10/30/two-sub-quadratic-sorts/#comment-735</link>
		<dc:creator><![CDATA[Posts about Programming from google blogs as of October 30, 2009 &#171; tryfly.com]]></dc:creator>
		<pubDate>Fri, 30 Oct 2009 23:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.com/?p=1567#comment-735</guid>
		<description><![CDATA[[...]  [...]]]></description>
		<content:encoded><![CDATA[<p>[...]  [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

