<?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"
	>
<channel>
	<title>Comments on: SICP section 2.3.3</title>
	<atom:link href="http://eli.thegreenplace.net/2007/09/11/sicp-section-233/feed/" rel="self" type="application/rss+xml" />
	<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/</link>
	<description>Eli Bendersky's personal website</description>
	<pubDate>Fri, 21 Nov 2008 22:12:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Chris Rathman</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-133363</link>
		<dc:creator>Chris Rathman</dc:creator>
		<pubDate>Wed, 08 Oct 2008 16:41:31 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-133363</guid>
		<description>Ok.  That makes sense.  Guess I'm too used to ML where an exception would be thrown.

Thanks for the explanation.</description>
		<content:encoded><![CDATA[<p>Ok.  That makes sense.  Guess I&#8217;m too used to ML where an exception would be thrown.</p>
<p>Thanks for the explanation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-133321</link>
		<dc:creator>eliben</dc:creator>
		<pubDate>Wed, 08 Oct 2008 05:39:50 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-133321</guid>
		<description>@Chris,

Since the solution is in Common Lisp, in which `&lt;code&gt;(car nil)&lt;/code&gt;` is `&lt;code&gt;nil&lt;/code&gt;`, the function does handle the case you refer to.</description>
		<content:encoded><![CDATA[<p>@Chris,</p>
<p>Since the solution is in Common Lisp, in which <code class="backtick">(car nil)</code> is <code class="backtick">nil</code>, the function does handle the case you refer to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Rathman</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-133291</link>
		<dc:creator>Chris Rathman</dc:creator>
		<pubDate>Fri, 03 Oct 2008 17:54:33 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-133291</guid>
		<description>The solution to exercise 2.62 does not seem to handle the case of set1 or set2 being null.

Not nitpicking.  I've been using your SICP solutions in my own translation efforts.  Need to get around to making sure I attribute your work.  And also need to get around to posting a story on lambda-the-ultimate.

Thanks.</description>
		<content:encoded><![CDATA[<p>The solution to exercise 2.62 does not seem to handle the case of set1 or set2 being null.</p>
<p>Not nitpicking.  I&#8217;ve been using your SICP solutions in my own translation efforts.  Need to get around to making sure I attribute your work.  And also need to get around to posting a story on lambda-the-ultimate.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-125668</link>
		<dc:creator>eliben</dc:creator>
		<pubDate>Wed, 13 Aug 2008 16:49:50 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-125668</guid>
		<description>Jason,
Thanks for sharing your thoughts.
In these notes I'm just attempting to answer the exercises, and what was asked is the order of growth. 
But I'm glad that people post further thoughts in comments, as it allows others to glean something deeper from the exercises.</description>
		<content:encoded><![CDATA[<p>Jason,<br />
Thanks for sharing your thoughts.<br />
In these notes I&#8217;m just attempting to answer the exercises, and what was asked is the order of growth.<br />
But I&#8217;m glad that people post further thoughts in comments, as it allows others to glean something deeper from the exercises.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-125606</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 12 Aug 2008 22:53:51 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-125606</guid>
		<description>Hi Eli, i'm also working through SICP, and i have a few comments about your analysis with regards to question 2.63. I believe tree-&#62;list-2 is faster than tree-&#62;list-1, if simply for the tail-recursive nature of tree-&#62;list-2. As you probably know, scheme optimizes for tail-recursion so that it does not use more stack space than their iterative siblings. Therefore, the overhead for calling functions repeatedly in tail-recursive versions are eliminated. Also, i do believe the algorithm in 2 is faster, since i believe in 2, it just visits each node once and cons the node element onto the result-list. When in 1, it is two recursions, and later appending the result from both into one list (append is a O(n) procedure). I haven't figured the second part completely, but intuition tells me 2 is faster than 1 in this regards as well. Also i do understand that two O(n) algorithms are formally equivalent, but a large constant can make or break an algorithm as well, and i do believe if nothing else, 2 has a smaller constant than 1, and you should probably mention that :D</description>
		<content:encoded><![CDATA[<p>Hi Eli, i&#8217;m also working through SICP, and i have a few comments about your analysis with regards to question 2.63. I believe tree-&gt;list-2 is faster than tree-&gt;list-1, if simply for the tail-recursive nature of tree-&gt;list-2. As you probably know, scheme optimizes for tail-recursion so that it does not use more stack space than their iterative siblings. Therefore, the overhead for calling functions repeatedly in tail-recursive versions are eliminated. Also, i do believe the algorithm in 2 is faster, since i believe in 2, it just visits each node once and cons the node element onto the result-list. When in 1, it is two recursions, and later appending the result from both into one list (append is a O(n) procedure). I haven&#8217;t figured the second part completely, but intuition tells me 2 is faster than 1 in this regards as well. Also i do understand that two O(n) algorithms are formally equivalent, but a large constant can make or break an algorithm as well, and i do believe if nothing else, 2 has a smaller constant than 1, and you should probably mention that <img src='http://eli.thegreenplace.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eliben</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-121071</link>
		<dc:creator>eliben</dc:creator>
		<pubDate>Tue, 13 May 2008 16:52:54 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-121071</guid>
		<description>Thanks for both comments - I have fixed the post.</description>
		<content:encoded><![CDATA[<p>Thanks for both comments - I have fixed the post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freefall</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-120325</link>
		<dc:creator>freefall</dc:creator>
		<pubDate>Tue, 29 Apr 2008 15:06:26 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-120325</guid>
		<description>Ex. 2.60: adjoin-set is O(1), indeed, as is cons. But union-set is O(n), because append needs to scan through its first argument.
Ex. 2.61: You can't use append here for the same reason -- it scans through its first argument -- and you use it once at each step of your adjoin-set-aux. That's classical Schlemiel-the-Painter as described in Joel on Software, an O(n^2) algorithm that's even worse than the O(n) for unordered lists. ElPicasso's "lazy" thing with sorting also won't do -- a decent sort is O(n * log n), AFAIR, not O(n/2). Only ElPicasso's last variant qualifies. That's what I was looking for, by the way, -- couldn't figure out how to do it iteratively without set-cdr!, but forgot that very recursive pattern used in append :)</description>
		<content:encoded><![CDATA[<p>Ex. 2.60: adjoin-set is O(1), indeed, as is cons. But union-set is O(n), because append needs to scan through its first argument.<br />
Ex. 2.61: You can&#8217;t use append here for the same reason &#8212; it scans through its first argument &#8212; and you use it once at each step of your adjoin-set-aux. That&#8217;s classical Schlemiel-the-Painter as described in Joel on Software, an O(n^2) algorithm that&#8217;s even worse than the O(n) for unordered lists. ElPicasso&#8217;s &#8220;lazy&#8221; thing with sorting also won&#8217;t do &#8212; a decent sort is O(n * log n), AFAIR, not O(n/2). Only ElPicasso&#8217;s last variant qualifies. That&#8217;s what I was looking for, by the way, &#8212; couldn&#8217;t figure out how to do it iteratively without set-cdr!, but forgot that very recursive pattern used in append <img src='http://eli.thegreenplace.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ElPicasso</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-97001</link>
		<dc:creator>ElPicasso</dc:creator>
		<pubDate>Mon, 07 Jan 2008 18:55:47 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-97001</guid>
		<description>ex 2.61
&lt;code&gt;
(define (adjoin-set x set)
  (cond ((null? set) (cons x ()))
	((&lt; x (car set)) (cons x set))
	((= x (car set)) set)
	(else (cons (car set) (adjoin-set x (cdr set))))))
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>ex 2.61<br />
<code><br />
(define (adjoin-set x set)<br />
  (cond ((null? set) (cons x ()))<br />
	((< x (car set)) (cons x set))<br />
	((= x (car set)) set)<br />
	(else (cons (car set) (adjoin-set x (cdr set))))))<br />
</code></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ElPicasso</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-96999</link>
		<dc:creator>ElPicasso</dc:creator>
		<pubDate>Mon, 07 Jan 2008 18:54:04 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-96999</guid>
		<description>ex 2.61 (bit lazy ...)
&lt;code&gt;
(define (adjoin-set x set)
  (if (element-of-set? x set)
      set
      (sort (cons x set) &lt;)))
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>ex 2.61 (bit lazy &#8230;)<br />
<code><br />
(define (adjoin-set x set)<br />
  (if (element-of-set? x set)<br />
      set<br />
      (sort (cons x set) < )))<br />
</code></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kenjin</title>
		<link>http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-91392</link>
		<dc:creator>Kenjin</dc:creator>
		<pubDate>Mon, 10 Dec 2007 06:38:59 +0000</pubDate>
		<guid isPermaLink="false">http://eli.thegreenplace.net/2007/09/11/sicp-section-233/#comment-91392</guid>
		<description>Thank you so much.
It would take a lot of time for me to understand it though,
if they are not explained as clear and easy as SICP,

Usually it takes longer for me to learn something than the average person.
But I study the book at least 12 hours a day. I just can't stop :)
I'm afraid now is the final exam season.
Thank you again.

I try very very hard not to see your answers. I want to do them myself.
It's too big a temptation:)</description>
		<content:encoded><![CDATA[<p>Thank you so much.<br />
It would take a lot of time for me to understand it though,<br />
if they are not explained as clear and easy as SICP,</p>
<p>Usually it takes longer for me to learn something than the average person.<br />
But I study the book at least 12 hours a day. I just can&#8217;t stop <img src='http://eli.thegreenplace.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I&#8217;m afraid now is the final exam season.<br />
Thank you again.</p>
<p>I try very very hard not to see your answers. I want to do them myself.<br />
It&#8217;s too big a temptation:)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
