<?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: Friday Algorithms: Iterative Quicksort</title>
	<atom:link href="/2010/06/18/friday-algorithms-iterative-quicksort/feed/" rel="self" type="application/rss+xml" />
	<link>/2010/06/18/friday-algorithms-iterative-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: John</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-474730</link>
		<dc:creator><![CDATA[John]]></dc:creator>
		<pubDate>Sun, 10 Dec 2017 19:27:51 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-474730</guid>
		<description><![CDATA[I did find a genuine bug though: The code fails if you try to sort an empty array. It turns &quot;[]&quot; into &quot;[undefined]&quot;.]]></description>
		<content:encoded><![CDATA[<p>I did find a genuine bug though: The code fails if you try to sort an empty array. It turns &#8220;[]&#8221; into &#8220;[undefined]&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-474726</link>
		<dc:creator><![CDATA[John]]></dc:creator>
		<pubDate>Sun, 10 Dec 2017 17:51:56 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-474726</guid>
		<description><![CDATA[I mean the example code has &quot;&#038;lt;&quot; instead of &quot;&#060;&quot;. The encoding is wrong ;P]]></description>
		<content:encoded><![CDATA[<p>I mean the example code has &#8220;&amp;lt;&#8221; instead of &#8220;&lt;&#8220;. The encoding is wrong ;P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-474725</link>
		<dc:creator><![CDATA[John]]></dc:creator>
		<pubDate>Sun, 10 Dec 2017 17:51:16 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-474725</guid>
		<description><![CDATA[@xgqfrms The only difference between your code and the article is that the article has &quot;&#060;&quot; instead of proper &quot;less than&quot; symbols. Anyone can fix that manually be replacing them with the real &quot;less than&quot; bracket symbol...

@stoimen Can you edit the webserver to properly encode &quot;less than&quot; code symbols?]]></description>
		<content:encoded><![CDATA[<p>@xgqfrms The only difference between your code and the article is that the article has &#8220;&lt;&#8221; instead of proper &#8220;less than&#8221; symbols. Anyone can fix that manually be replacing them with the real &#8220;less than&#8221; bracket symbol&#8230;</p>
<p>@stoimen Can you edit the webserver to properly encode &#8220;less than&#8221; code symbols?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xgqfrms</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-435601</link>
		<dc:creator><![CDATA[xgqfrms]]></dc:creator>
		<pubDate>Thu, 22 Dec 2016 09:22:14 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-435601</guid>
		<description><![CDATA[https://repl.it/Ev1E/12
# javascript demo codes bugs fixed:
```js
var a = [8, 4, 6, 2, 1, 9, 5, 5, 4, 3, 4, 3];

function qsort(arr) {
    var stack = [arr];
    var sorted = [];
    while (stack.length) {
        var temp = stack.pop(),
            tl = temp.length;
        if (tl == 1) {
            sorted.push(temp[0]);
            continue;
        }
        var pivot = temp[0];
        var left = [],
            right = [];
        for (var i = 1; i &#060; tl; i++) {
            if (temp[i] &#060; pivot) {
                left.push(temp[i]);
            } else {
                right.push(temp[i]);
            }
        }
        left.push(pivot);
        if (right.length)
            stack.push(right);
        if (left.length)
            stack.push(left);
    }
    console.log(&#034;sorted = &#034; + sorted);
    console.log(&#034;typeof = &#034; + typeof sorted);
    // return sorted[0] + &#034;,&#034; + sorted[1] + &#034;,&#034; + sorted[2] + &#034;,&#034; + sorted[3] + &#034;,&#034; + sorted[4] + &#034;,&#034; + sorted[5] + &#034;,&#034; + sorted[6] + &#034;,&#034; + sorted[7] + &#034;,&#034; + sorted[8];
}
qsort(a);

//console.log(&#034;sorted = &#034; + qsort(a));
```]]></description>
		<content:encoded><![CDATA[<p><a href="https://repl.it/Ev1E/12" rel="nofollow">https://repl.it/Ev1E/12</a><br />
# javascript demo codes bugs fixed:<br />
&#8220;`js<br />
var a = [8, 4, 6, 2, 1, 9, 5, 5, 4, 3, 4, 3];</p>
<p>function qsort(arr) {<br />
    var stack = [arr];<br />
    var sorted = [];<br />
    while (stack.length) {<br />
        var temp = stack.pop(),<br />
            tl = temp.length;<br />
        if (tl == 1) {<br />
            sorted.push(temp[0]);<br />
            continue;<br />
        }<br />
        var pivot = temp[0];<br />
        var left = [],<br />
            right = [];<br />
        for (var i = 1; i &lt; tl; i++) {<br />
            if (temp[i] &lt; pivot) {<br />
                left.push(temp[i]);<br />
            } else {<br />
                right.push(temp[i]);<br />
            }<br />
        }<br />
        left.push(pivot);<br />
        if (right.length)<br />
            stack.push(right);<br />
        if (left.length)<br />
            stack.push(left);<br />
    }<br />
    console.log(&quot;sorted = &quot; + sorted);<br />
    console.log(&quot;typeof = &quot; + typeof sorted);<br />
    // return sorted[0] + &quot;,&quot; + sorted[1] + &quot;,&quot; + sorted[2] + &quot;,&quot; + sorted[3] + &quot;,&quot; + sorted[4] + &quot;,&quot; + sorted[5] + &quot;,&quot; + sorted[6] + &quot;,&quot; + sorted[7] + &quot;,&quot; + sorted[8];<br />
}<br />
qsort(a);</p>
<p>//console.log(&quot;sorted = &quot; + qsort(a));<br />
&#8220;`</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mateevici</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-16269</link>
		<dc:creator><![CDATA[Mateevici]]></dc:creator>
		<pubDate>Fri, 06 Jul 2012 13:49:24 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-16269</guid>
		<description><![CDATA[Hi!

Great post!

Still, I must object to the correctness of the algorithm.
Correct me if I&#039;m wrong, but if the pivot element is equal to the maximum of the sub-sequence, the algorithm loops forever. Just add the pivot as a separate sub-sequence to the stack and all should be fine. Right?

Have a great day!]]></description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>Great post!</p>
<p>Still, I must object to the correctness of the algorithm.<br />
Correct me if I&#8217;m wrong, but if the pivot element is equal to the maximum of the sub-sequence, the algorithm loops forever. Just add the pivot as a separate sub-sequence to the stack and all should be fine. Right?</p>
<p>Have a great day!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stoimen</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-14264</link>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
		<pubDate>Wed, 20 Apr 2011 09:43:05 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-14264</guid>
		<description><![CDATA[@R.Arce - great example thanx!]]></description>
		<content:encoded><![CDATA[<p>@R.Arce &#8211; great example thanx!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R. Arce</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-14260</link>
		<dc:creator><![CDATA[R. Arce]]></dc:creator>
		<pubDate>Tue, 19 Apr 2011 21:00:32 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-14260</guid>
		<description><![CDATA[In case your readers are interested, here is a c++ version..
&lt;pre lang=&quot;c&quot; escaped=&quot;true&quot;&gt;
#include 
#include 

using namespace std;

vector qs_iterative(vector &#038; v) {
	// convert to a vector of vectors
	vector&#060; vector  &#062; vv;
	vector  tmp;
	vector  sorted;
	
	
	vv.push_back(v);
	
	while (!vv.empty()) {
		tmp = vv.back();
		vv.pop_back();
		if (tmp.size()==1) sorted.push_back(tmp.back());
		
		else {
			int pivot = tmp[0];
			vector  left, right;
	 
			for (int i = 1; i &#060; tmp.size(); i++) {
				if (tmp[i]  0) vv.push_back(right);
			if (left.size()  &#062; 0) vv.push_back(left);
			}
	}
	return sorted;
}
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>In case your readers are interested, here is a c++ version..</p>
<pre lang="c" escaped="true">
#include 
#include 

using namespace std;

vector qs_iterative(vector &amp; v) {
	// convert to a vector of vectors
	vector&lt; vector  &gt; vv;
	vector  tmp;
	vector  sorted;
	
	
	vv.push_back(v);
	
	while (!vv.empty()) {
		tmp = vv.back();
		vv.pop_back();
		if (tmp.size()==1) sorted.push_back(tmp.back());
		
		else {
			int pivot = tmp[0];
			vector  left, right;
	 
			for (int i = 1; i &lt; tmp.size(); i++) {
				if (tmp[i]  0) vv.push_back(right);
			if (left.size()  &gt; 0) vv.push_back(left);
			}
	}
	return sorted;
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-14131</link>
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-14131</guid>
		<description><![CDATA[i&#039;m sorry it did not work out:
&lt;pre lang=&quot;c&quot; escaped=&quot;true&quot;&gt;
for (var i = 1; i &#060; tl; i++) {
            if (temp[i] &#060; pivot) {
                left.push(temp[i]);
            } else {
                right.push(temp[i]);
            }
        }
&lt;/pre&gt;

did you mean
&lt;pre lang=&quot;c&quot; escaped=&quot;true&quot;&gt;
for (var i = 1; i &#060; tl; i++) {
    if (temp[i] &#060; pivot) {
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>i&#8217;m sorry it did not work out:</p>
<pre lang="c" escaped="true">
for (var i = 1; i &lt; tl; i++) {
            if (temp[i] &lt; pivot) {
                left.push(temp[i]);
            } else {
                right.push(temp[i]);
            }
        }
</pre>
<p>did you mean</p>
<pre lang="c" escaped="true">
for (var i = 1; i &lt; tl; i++) {
    if (temp[i] &lt; pivot) {
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>/2010/06/18/friday-algorithms-iterative-quicksort/comment-page-1/#comment-14130</link>
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 27 Dec 2010 15:55:59 +0000</pubDate>
		<guid isPermaLink="false">/?p=1631#comment-14130</guid>
		<description><![CDATA[Hi. At first, happy christmas and thanks for the work.
I&#039;m trying to port the algorithm to c#.
Is there a problem with the following strings?
&lt;pre lang=&quot;c&quot; escaped=&quot;true&quot;&gt;
for (var i = 1; i &#060; tl; i++) {
            if (temp[i] &#060; pivot) {
&lt;/pre&gt;
did you mean
&lt;pre lang=&quot;c&quot; escaped=&quot;true&quot;&gt;
for (var i = 1; i &#060; tl; i++) {
            if (temp[i] &#060; pivot) {
&lt;/pre&gt;
?
Thanks in advance.]]></description>
		<content:encoded><![CDATA[<p>Hi. At first, happy christmas and thanks for the work.<br />
I&#8217;m trying to port the algorithm to c#.<br />
Is there a problem with the following strings?</p>
<pre lang="c" escaped="true">
for (var i = 1; i &lt; tl; i++) {
            if (temp[i] &lt; pivot) {
</pre>
<p>did you mean</p>
<pre lang="c" escaped="true">
for (var i = 1; i &lt; tl; i++) {
            if (temp[i] &lt; pivot) {
</pre>
<p>?<br />
Thanks in advance.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
