<?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: Who&#8217;s up for a challenge?</title>
	<atom:link href="http://buffered.io/2006/09/15/whos-up-for-a-challenge/feed/" rel="self" type="application/rss+xml" />
	<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/</link>
	<description>What would OJ do?</description>
	<lastBuildDate>Wed, 08 Sep 2010 02:50:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: OJ</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-32</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Sat, 16 Sep 2006 11:05:29 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-32</guid>
		<description>One more thing that I&#039;d like to say: Keef&#039;s solution is commonly known as the &quot;two-walker&quot; method (apparently), though I can&#039;t seem to find a link that backs that up :)</description>
		<content:encoded><![CDATA[<p>One more thing that I&#8217;d like to say: Keef&#8217;s solution is commonly known as the &#8220;two-walker&#8221; method (apparently), though I can&#8217;t seem to find a link that backs that up <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-2212</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Sat, 16 Sep 2006 11:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-2212</guid>
		<description>One more thing that I&#039;d like to say: Keef&#039;s solution is commonly known as the &quot;two-walker&quot; method (apparently), though I can&#039;t seem to find a link that backs that up :)</description>
		<content:encoded><![CDATA[<p>One more thing that I&#8217;d like to say: Keef&#8217;s solution is commonly known as the &#8220;two-walker&#8221; method (apparently), though I can&#8217;t seem to find a link that backs that up <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-31</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Sat, 16 Sep 2006 10:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-31</guid>
		<description>I&#039;ve just had a nose through the RubyQuiz link that you posted and there does seem to be some good puzzles on there to solve. I think that for the most part they are a little larger than what I intend to post on here, which is a good thing! At least if people become bored with small questions and are looking to get their teeth into something bigger then they can head over there solve until their heart&#039;s content. I&#039;ll do my best (but that doesn&#039;t mean I&#039;ll nail it all the time ;)) to post questions that focus on a very small blob of code or a particular algorithm.

Thanks again.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve just had a nose through the RubyQuiz link that you posted and there does seem to be some good puzzles on there to solve. I think that for the most part they are a little larger than what I intend to post on here, which is a good thing! At least if people become bored with small questions and are looking to get their teeth into something bigger then they can head over there solve until their heart&#8217;s content. I&#8217;ll do my best (but that doesn&#8217;t mean I&#8217;ll nail it all the time ;)) to post questions that focus on a very small blob of code or a particular algorithm.</p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-2211</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Sat, 16 Sep 2006 10:46:00 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-2211</guid>
		<description>I&#039;ve just had a nose through the RubyQuiz link that you posted and there does seem to be some good puzzles on there to solve. I think that for the most part they are a little larger than what I intend to post on here, which is a good thing! At least if people become bored with small questions and are looking to get their teeth into something bigger then they can head over there solve until their heart&#039;s content. I&#039;ll do my best (but that doesn&#039;t mean I&#039;ll nail it all the time ;)) to post questions that focus on a very small blob of code or a particular algorithm.

Thanks again.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve just had a nose through the RubyQuiz link that you posted and there does seem to be some good puzzles on there to solve. I think that for the most part they are a little larger than what I intend to post on here, which is a good thing! At least if people become bored with small questions and are looking to get their teeth into something bigger then they can head over there solve until their heart&#8217;s content. I&#8217;ll do my best (but that doesn&#8217;t mean I&#8217;ll nail it all the time ;)) to post questions that focus on a very small blob of code or a particular algorithm.</p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-30</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Sat, 16 Sep 2006 10:39:36 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-30</guid>
		<description>I hadn&#039;t seen the RubyQuiz link before today, thanks for posting it. It does look like it could be a bit of fun! I&#039;ll probably keep tabs on that one while I continue to play with Ruby, as it&#039;s a language that I&#039;m yet to delve into in depth.

I see the challenge did get you thinking :) Of course, there are usually a bunch of other issues that come along with a problem like this, and I think you may well have covered most, if not all, of them.

I tried to write the definition of the problem in a very compact way in an attempt to focus people on the algorithm rather than the code. This of course forced me (and you guys) to make some assumptions about the code where this might occur.

In an ideal world, there would of course be some form of list management structure/object that ensures that a &quot;loop&quot; such as this would never occur. My assumption here is that, even if there is a list management structure, there is a bug in the code which results in the list incorrectly becoming a circular list - &lt;em&gt;at an unknown point&lt;/em&gt;.

That&#039;s probably the key piece of information that I left out of the problem spec, but I did that for a reason also - to see what solutions come through which attempt to cater for &lt;em&gt;any&lt;/em&gt; loop scenario.

I have actually seen this sort of issue happen in the real world. The most common place you see things like this (in my experience) is where code is attempting to manage one or more &quot;free lists&quot; where the nodes can switch between the lists.

Example: You&#039;re writing a little memory manager that is responsible for allocating a block of memory which can be used by a collection of objects, let&#039;s say of type &lt;strong&gt;T&lt;/strong&gt;. On start-up, the memory manager allocates a chunk of memory to allow for the use of up to &lt;strong&gt;N&lt;/strong&gt; lots of T at any given time, and it manages that chunk of memory using two separate free lists. At the start, the &quot;allocated&quot; list is empty, and the &quot;unallocated&quot; list has all the nodes in it. As the program continues to execute, and calling objects request allocation of memory for type T, the memory allocator simply removes a node from the &quot;unallocated&quot; list to the &quot;allocated&quot; list (by switching a few pointers around), and returns a reference to the newly &quot;allocated&quot; instance of T for the caller to use. Depending on how good (or bad :)) the author of this memory manager was, issues such as loops in the list can unfortunately become a reality. In this scenario, it is possible, through incorrect ordering of steps or bad management of pointers across the two structures, that the loop can occur almost anywhere in either of the free lists.

So while this may be unlikely when, for the most part, there are already a bunch of implementations of lists that people use day in day out it can actually appear in the wild. The purpose of the question was to attempt to come up with a way of determining if a list contains such a loop. I see it more as a debugging utility than anything else.

You&#039;re entitled to get pedantic :) That&#039;s what this is about! I think your posts are interesting, and in the case where an official &quot;singly linked-list&quot; (or is it &quot;singularly&quot;?) becomes an official &quot;circular linked-list&quot;, your solution would indeed be fastest. Of course, in the case where we don&#039;t exactly know where the loop in the list occurs, this wouldn&#039;t give us the result we&#039;re looking for, and this is where Keith&#039;s solution shines.

Thanks for the posts guys :)</description>
		<content:encoded><![CDATA[<p>I hadn&#8217;t seen the RubyQuiz link before today, thanks for posting it. It does look like it could be a bit of fun! I&#8217;ll probably keep tabs on that one while I continue to play with Ruby, as it&#8217;s a language that I&#8217;m yet to delve into in depth.</p>
<p>I see the challenge did get you thinking <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> Of course, there are usually a bunch of other issues that come along with a problem like this, and I think you may well have covered most, if not all, of them.</p>
<p>I tried to write the definition of the problem in a very compact way in an attempt to focus people on the algorithm rather than the code. This of course forced me (and you guys) to make some assumptions about the code where this might occur.</p>
<p>In an ideal world, there would of course be some form of list management structure/object that ensures that a &#8220;loop&#8221; such as this would never occur. My assumption here is that, even if there is a list management structure, there is a bug in the code which results in the list incorrectly becoming a circular list &#8211; <em>at an unknown point</em>.</p>
<p>That&#8217;s probably the key piece of information that I left out of the problem spec, but I did that for a reason also &#8211; to see what solutions come through which attempt to cater for <em>any</em> loop scenario.</p>
<p>I have actually seen this sort of issue happen in the real world. The most common place you see things like this (in my experience) is where code is attempting to manage one or more &#8220;free lists&#8221; where the nodes can switch between the lists.</p>
<p>Example: You&#8217;re writing a little memory manager that is responsible for allocating a block of memory which can be used by a collection of objects, let&#8217;s say of type <strong>T</strong>. On start-up, the memory manager allocates a chunk of memory to allow for the use of up to <strong>N</strong> lots of T at any given time, and it manages that chunk of memory using two separate free lists. At the start, the &#8220;allocated&#8221; list is empty, and the &#8220;unallocated&#8221; list has all the nodes in it. As the program continues to execute, and calling objects request allocation of memory for type T, the memory allocator simply removes a node from the &#8220;unallocated&#8221; list to the &#8220;allocated&#8221; list (by switching a few pointers around), and returns a reference to the newly &#8220;allocated&#8221; instance of T for the caller to use. Depending on how good (or bad :)) the author of this memory manager was, issues such as loops in the list can unfortunately become a reality. In this scenario, it is possible, through incorrect ordering of steps or bad management of pointers across the two structures, that the loop can occur almost anywhere in either of the free lists.</p>
<p>So while this may be unlikely when, for the most part, there are already a bunch of implementations of lists that people use day in day out it can actually appear in the wild. The purpose of the question was to attempt to come up with a way of determining if a list contains such a loop. I see it more as a debugging utility than anything else.</p>
<p>You&#8217;re entitled to get pedantic <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> That&#8217;s what this is about! I think your posts are interesting, and in the case where an official &#8220;singly linked-list&#8221; (or is it &#8220;singularly&#8221;?) becomes an official &#8220;circular linked-list&#8221;, your solution would indeed be fastest. Of course, in the case where we don&#8217;t exactly know where the loop in the list occurs, this wouldn&#8217;t give us the result we&#8217;re looking for, and this is where Keith&#8217;s solution shines.</p>
<p>Thanks for the posts guys <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OJ</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-2210</link>
		<dc:creator>OJ</dc:creator>
		<pubDate>Sat, 16 Sep 2006 10:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-2210</guid>
		<description>I hadn&#039;t seen the RubyQuiz link before today, thanks for posting it. It does look like it could be a bit of fun! I&#039;ll probably keep tabs on that one while I continue to play with Ruby, as it&#039;s a language that I&#039;m yet to delve into in depth.

I see the challenge did get you thinking :) Of course, there are usually a bunch of other issues that come along with a problem like this, and I think you may well have covered most, if not all, of them.

I tried to write the definition of the problem in a very compact way in an attempt to focus people on the algorithm rather than the code. This of course forced me (and you guys) to make some assumptions about the code where this might occur.

In an ideal world, there would of course be some form of list management structure/object that ensures that a &quot;loop&quot; such as this would never occur. My assumption here is that, even if there is a list management structure, there is a bug in the code which results in the list incorrectly becoming a circular list - &lt;em&gt;at an unknown point&lt;/em&gt;.

That&#039;s probably the key piece of information that I left out of the problem spec, but I did that for a reason also - to see what solutions come through which attempt to cater for &lt;em&gt;any&lt;/em&gt; loop scenario.

I have actually seen this sort of issue happen in the real world. The most common place you see things like this (in my experience) is where code is attempting to manage one or more &quot;free lists&quot; where the nodes can switch between the lists.

Example: You&#039;re writing a little memory manager that is responsible for allocating a block of memory which can be used by a collection of objects, let&#039;s say of type &lt;strong&gt;T&lt;/strong&gt;. On start-up, the memory manager allocates a chunk of memory to allow for the use of up to &lt;strong&gt;N&lt;/strong&gt; lots of T at any given time, and it manages that chunk of memory using two separate free lists. At the start, the &quot;allocated&quot; list is empty, and the &quot;unallocated&quot; list has all the nodes in it. As the program continues to execute, and calling objects request allocation of memory for type T, the memory allocator simply removes a node from the &quot;unallocated&quot; list to the &quot;allocated&quot; list (by switching a few pointers around), and returns a reference to the newly &quot;allocated&quot; instance of T for the caller to use. Depending on how good (or bad :)) the author of this memory manager was, issues such as loops in the list can unfortunately become a reality. In this scenario, it is possible, through incorrect ordering of steps or bad management of pointers across the two structures, that the loop can occur almost anywhere in either of the free lists.

So while this may be unlikely when, for the most part, there are already a bunch of implementations of lists that people use day in day out it can actually appear in the wild. The purpose of the question was to attempt to come up with a way of determining if a list contains such a loop. I see it more as a debugging utility than anything else.

You&#039;re entitled to get pedantic :) That&#039;s what this is about! I think your posts are interesting, and in the case where an official &quot;singly linked-list&quot; (or is it &quot;singularly&quot;?) becomes an official &quot;circular linked-list&quot;, your solution would indeed be fastest. Of course, in the case where we don&#039;t exactly know where the loop in the list occurs, this wouldn&#039;t give us the result we&#039;re looking for, and this is where Keith&#039;s solution shines.

Thanks for the posts guys :)</description>
		<content:encoded><![CDATA[<p>I hadn&#8217;t seen the RubyQuiz link before today, thanks for posting it. It does look like it could be a bit of fun! I&#8217;ll probably keep tabs on that one while I continue to play with Ruby, as it&#8217;s a language that I&#8217;m yet to delve into in depth.</p>
<p>I see the challenge did get you thinking <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> Of course, there are usually a bunch of other issues that come along with a problem like this, and I think you may well have covered most, if not all, of them.</p>
<p>I tried to write the definition of the problem in a very compact way in an attempt to focus people on the algorithm rather than the code. This of course forced me (and you guys) to make some assumptions about the code where this might occur.</p>
<p>In an ideal world, there would of course be some form of list management structure/object that ensures that a &#8220;loop&#8221; such as this would never occur. My assumption here is that, even if there is a list management structure, there is a bug in the code which results in the list incorrectly becoming a circular list &#8211; <em>at an unknown point</em>.</p>
<p>That&#8217;s probably the key piece of information that I left out of the problem spec, but I did that for a reason also &#8211; to see what solutions come through which attempt to cater for <em>any</em> loop scenario.</p>
<p>I have actually seen this sort of issue happen in the real world. The most common place you see things like this (in my experience) is where code is attempting to manage one or more &#8220;free lists&#8221; where the nodes can switch between the lists.</p>
<p>Example: You&#8217;re writing a little memory manager that is responsible for allocating a block of memory which can be used by a collection of objects, let&#8217;s say of type <strong>T</strong>. On start-up, the memory manager allocates a chunk of memory to allow for the use of up to <strong>N</strong> lots of T at any given time, and it manages that chunk of memory using two separate free lists. At the start, the &#8220;allocated&#8221; list is empty, and the &#8220;unallocated&#8221; list has all the nodes in it. As the program continues to execute, and calling objects request allocation of memory for type T, the memory allocator simply removes a node from the &#8220;unallocated&#8221; list to the &#8220;allocated&#8221; list (by switching a few pointers around), and returns a reference to the newly &#8220;allocated&#8221; instance of T for the caller to use. Depending on how good (or bad :)) the author of this memory manager was, issues such as loops in the list can unfortunately become a reality. In this scenario, it is possible, through incorrect ordering of steps or bad management of pointers across the two structures, that the loop can occur almost anywhere in either of the free lists.</p>
<p>So while this may be unlikely when, for the most part, there are already a bunch of implementations of lists that people use day in day out it can actually appear in the wild. The purpose of the question was to attempt to come up with a way of determining if a list contains such a loop. I see it more as a debugging utility than anything else.</p>
<p>You&#8217;re entitled to get pedantic <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> That&#8217;s what this is about! I think your posts are interesting, and in the case where an official &#8220;singly linked-list&#8221; (or is it &#8220;singularly&#8221;?) becomes an official &#8220;circular linked-list&#8221;, your solution would indeed be fastest. Of course, in the case where we don&#8217;t exactly know where the loop in the list occurs, this wouldn&#8217;t give us the result we&#8217;re looking for, and this is where Keith&#8217;s solution shines.</p>
<p>Thanks for the posts guys <img src='http://buffered.io/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Wright</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-29</link>
		<dc:creator>Pete Wright</dc:creator>
		<pubDate>Sat, 16 Sep 2006 03:32:36 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-29</guid>
		<description>Now this is really bugging me.

So, let&#039;s assuming we don&#039;t have a list managing structure; we simply have items in memory that point to their successor and have no choice but to traverse the list to examine whether or not it is null terminated.

The solution posted by Keef in that respect then is horribly inefficient since you can&#039;t actually traverse the list at different speeds at all; each node only knows about its successor. So, the &#039;faster&#039; mover actually has to read a node and check the successor twice for each one check made by the slower mover. It&#039;s late here and I don&#039;t want to do the math but you will end up traversing the entire list at least 1.5 times I think.

So, the simplest solution is (since you know the first element of the list - you&#039;ve got to start somewhere) is to simply sequentially move through the list until a successor is null (it&#039;s a singly linked list) or you get back at the start. The most you would traverse then, assuming you start at the very first node, is once, and you&#039;d check each node just once, rather than 3 times (the slow mover checking each node, and the fast mover checking each node and the successor node in order to leap ahead).</description>
		<content:encoded><![CDATA[<p>Now this is really bugging me.</p>
<p>So, let&#8217;s assuming we don&#8217;t have a list managing structure; we simply have items in memory that point to their successor and have no choice but to traverse the list to examine whether or not it is null terminated.</p>
<p>The solution posted by Keef in that respect then is horribly inefficient since you can&#8217;t actually traverse the list at different speeds at all; each node only knows about its successor. So, the &#8216;faster&#8217; mover actually has to read a node and check the successor twice for each one check made by the slower mover. It&#8217;s late here and I don&#8217;t want to do the math but you will end up traversing the entire list at least 1.5 times I think.</p>
<p>So, the simplest solution is (since you know the first element of the list &#8211; you&#8217;ve got to start somewhere) is to simply sequentially move through the list until a successor is null (it&#8217;s a singly linked list) or you get back at the start. The most you would traverse then, assuming you start at the very first node, is once, and you&#8217;d check each node just once, rather than 3 times (the slow mover checking each node, and the fast mover checking each node and the successor node in order to leap ahead).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Wright</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-2209</link>
		<dc:creator>Pete Wright</dc:creator>
		<pubDate>Sat, 16 Sep 2006 03:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-2209</guid>
		<description>Now this is really bugging me.

So, let&#039;s assuming we don&#039;t have a list managing structure; we simply have items in memory that point to their successor and have no choice but to traverse the list to examine whether or not it is null terminated.

The solution posted by Keef in that respect then is horribly inefficient since you can&#039;t actually traverse the list at different speeds at all; each node only knows about its successor. So, the &#039;faster&#039; mover actually has to read a node and check the successor twice for each one check made by the slower mover. It&#039;s late here and I don&#039;t want to do the math but you will end up traversing the entire list at least 1.5 times I think.

So, the simplest solution is (since you know the first element of the list - you&#039;ve got to start somewhere) is to simply sequentially move through the list until a successor is null (it&#039;s a singly linked list) or you get back at the start. The most you would traverse then, assuming you start at the very first node, is once, and you&#039;d check each node just once, rather than 3 times (the slow mover checking each node, and the fast mover checking each node and the successor node in order to leap ahead).</description>
		<content:encoded><![CDATA[<p>Now this is really bugging me.</p>
<p>So, let&#8217;s assuming we don&#8217;t have a list managing structure; we simply have items in memory that point to their successor and have no choice but to traverse the list to examine whether or not it is null terminated.</p>
<p>The solution posted by Keef in that respect then is horribly inefficient since you can&#8217;t actually traverse the list at different speeds at all; each node only knows about its successor. So, the &#8216;faster&#8217; mover actually has to read a node and check the successor twice for each one check made by the slower mover. It&#8217;s late here and I don&#8217;t want to do the math but you will end up traversing the entire list at least 1.5 times I think.</p>
<p>So, the simplest solution is (since you know the first element of the list &#8211; you&#8217;ve got to start somewhere) is to simply sequentially move through the list until a successor is null (it&#8217;s a singly linked list) or you get back at the start. The most you would traverse then, assuming you start at the very first node, is once, and you&#8217;d check each node just once, rather than 3 times (the slow mover checking each node, and the fast mover checking each node and the successor node in order to leap ahead).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Wright</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-28</link>
		<dc:creator>Pete Wright</dc:creator>
		<pubDate>Sat, 16 Sep 2006 03:21:27 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-28</guid>
		<description>Looking at the problem you posted though, I&#039;m tempted to get pedantic. Knuth documented linked and circular lists in volume 1 of The Art of Programming. They are different structures. Thus, if you had a situation where you were concerned that a linked list may have become circular the obvious concern would be whether or not the implementation of the list itself is correct.

A classic singly linked list (one which tracks only the first entry in the list, with each node knowing only the node that follows) is limited in usefulness in terms of adding new items; unless you want to walk sequentially through the entire list to find the last and update its &#039;next&#039; pointer, you are limited to only adding items to the front of the list. The class or construct managing the list would then be responsible for updating the &#039;next&#039; pointer of this new item to point to that which was previously first. In that respect, if the class implementing the linked list is properly implemented, it woudl be impossible to have the list become circular surely? (consumers of the list rely on the list to manage itself). The list is merely an organisational representation of data, and thus the consumer or producer of the data would not ever be concerned with the semantics of the list&#039;s own pointers.

Similarly, a circular singly linked list would be implemented in such a way that two pointers are updated on the addition of a new entry; the next pointer of the last item, and the next pointer of the new item. Such a construct would by nature of its design have to manage the circular link (but as Knuth points out there are problems to be aware of when managing a circular singly linked list that could be empty - pg274).

So, the upshot from a design standpoint is that if there is a risk that your singly linked list has in fact become circular, giving rise to the need to write code to determine if that&#039;s the case, then surely refactoring driven by tests to implement an effective list-structure-manager construct would be the best way forward to not only address the potential bug, but also shore up the architecture of the solution at hand.</description>
		<content:encoded><![CDATA[<p>Looking at the problem you posted though, I&#8217;m tempted to get pedantic. Knuth documented linked and circular lists in volume 1 of The Art of Programming. They are different structures. Thus, if you had a situation where you were concerned that a linked list may have become circular the obvious concern would be whether or not the implementation of the list itself is correct.</p>
<p>A classic singly linked list (one which tracks only the first entry in the list, with each node knowing only the node that follows) is limited in usefulness in terms of adding new items; unless you want to walk sequentially through the entire list to find the last and update its &#8216;next&#8217; pointer, you are limited to only adding items to the front of the list. The class or construct managing the list would then be responsible for updating the &#8216;next&#8217; pointer of this new item to point to that which was previously first. In that respect, if the class implementing the linked list is properly implemented, it woudl be impossible to have the list become circular surely? (consumers of the list rely on the list to manage itself). The list is merely an organisational representation of data, and thus the consumer or producer of the data would not ever be concerned with the semantics of the list&#8217;s own pointers.</p>
<p>Similarly, a circular singly linked list would be implemented in such a way that two pointers are updated on the addition of a new entry; the next pointer of the last item, and the next pointer of the new item. Such a construct would by nature of its design have to manage the circular link (but as Knuth points out there are problems to be aware of when managing a circular singly linked list that could be empty &#8211; pg274).</p>
<p>So, the upshot from a design standpoint is that if there is a risk that your singly linked list has in fact become circular, giving rise to the need to write code to determine if that&#8217;s the case, then surely refactoring driven by tests to implement an effective list-structure-manager construct would be the best way forward to not only address the potential bug, but also shore up the architecture of the solution at hand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete Wright</title>
		<link>http://buffered.io/2006/09/15/whos-up-for-a-challenge/comment-page-1/#comment-2208</link>
		<dc:creator>Pete Wright</dc:creator>
		<pubDate>Sat, 16 Sep 2006 03:21:00 +0000</pubDate>
		<guid isPermaLink="false">http://buffered.io/?p=9#comment-2208</guid>
		<description>Looking at the problem you posted though, I&#039;m tempted to get pedantic. Knuth documented linked and circular lists in volume 1 of The Art of Programming. They are different structures. Thus, if you had a situation where you were concerned that a linked list may have become circular the obvious concern would be whether or not the implementation of the list itself is correct.

A classic singly linked list (one which tracks only the first entry in the list, with each node knowing only the node that follows) is limited in usefulness in terms of adding new items; unless you want to walk sequentially through the entire list to find the last and update its &#039;next&#039; pointer, you are limited to only adding items to the front of the list. The class or construct managing the list would then be responsible for updating the &#039;next&#039; pointer of this new item to point to that which was previously first. In that respect, if the class implementing the linked list is properly implemented, it woudl be impossible to have the list become circular surely? (consumers of the list rely on the list to manage itself). The list is merely an organisational representation of data, and thus the consumer or producer of the data would not ever be concerned with the semantics of the list&#039;s own pointers.

Similarly, a circular singly linked list would be implemented in such a way that two pointers are updated on the addition of a new entry; the next pointer of the last item, and the next pointer of the new item. Such a construct would by nature of its design have to manage the circular link (but as Knuth points out there are problems to be aware of when managing a circular singly linked list that could be empty - pg274).

So, the upshot from a design standpoint is that if there is a risk that your singly linked list has in fact become circular, giving rise to the need to write code to determine if that&#039;s the case, then surely refactoring driven by tests to implement an effective list-structure-manager construct would be the best way forward to not only address the potential bug, but also shore up the architecture of the solution at hand.</description>
		<content:encoded><![CDATA[<p>Looking at the problem you posted though, I&#8217;m tempted to get pedantic. Knuth documented linked and circular lists in volume 1 of The Art of Programming. They are different structures. Thus, if you had a situation where you were concerned that a linked list may have become circular the obvious concern would be whether or not the implementation of the list itself is correct.</p>
<p>A classic singly linked list (one which tracks only the first entry in the list, with each node knowing only the node that follows) is limited in usefulness in terms of adding new items; unless you want to walk sequentially through the entire list to find the last and update its &#8216;next&#8217; pointer, you are limited to only adding items to the front of the list. The class or construct managing the list would then be responsible for updating the &#8216;next&#8217; pointer of this new item to point to that which was previously first. In that respect, if the class implementing the linked list is properly implemented, it woudl be impossible to have the list become circular surely? (consumers of the list rely on the list to manage itself). The list is merely an organisational representation of data, and thus the consumer or producer of the data would not ever be concerned with the semantics of the list&#8217;s own pointers.</p>
<p>Similarly, a circular singly linked list would be implemented in such a way that two pointers are updated on the addition of a new entry; the next pointer of the last item, and the next pointer of the new item. Such a construct would by nature of its design have to manage the circular link (but as Knuth points out there are problems to be aware of when managing a circular singly linked list that could be empty &#8211; pg274).</p>
<p>So, the upshot from a design standpoint is that if there is a risk that your singly linked list has in fact become circular, giving rise to the need to write code to determine if that&#8217;s the case, then surely refactoring driven by tests to implement an effective list-structure-manager construct would be the best way forward to not only address the potential bug, but also shore up the architecture of the solution at hand.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
