<?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: Interview Questions: Loops in Linked Lists</title>
	<atom:link href="http://20bits.com/articles/interview-questions-loops-in-linked-lists/feed/" rel="self" type="application/rss+xml" />
	<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/</link>
	<description>Driven by Data</description>
	<lastBuildDate>Wed, 28 Jul 2010 21:50:46 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: 800 calorie diet</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-5093</link>
		<dc:creator>800 calorie diet</dc:creator>
		<pubDate>Tue, 13 Jul 2010 01:17:40 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-5093</guid>
		<description>Golden. Great, useful info.</description>
		<content:encoded><![CDATA[<p>Golden. Great, useful info.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Air Climber</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-5073</link>
		<dc:creator>Air Climber</dc:creator>
		<pubDate>Sat, 03 Jul 2010 21:36:13 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-5073</guid>
		<description>No this has to be a web programming language</description>
		<content:encoded><![CDATA[<p>No this has to be a web programming language</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Magic Jack</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-5074</link>
		<dc:creator>Magic Jack</dc:creator>
		<pubDate>Fri, 02 Jul 2010 20:07:53 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-5074</guid>
		<description>Is this for C++?</description>
		<content:encoded><![CDATA[<p>Is this for C++?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vidarislying</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-5075</link>
		<dc:creator>vidarislying</dc:creator>
		<pubDate>Thu, 01 Jul 2010 18:22:54 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-5075</guid>
		<description>Sorry to say vidar you&#039;re blowing hot air out some orifice! the tortoise and hare solution you claim to have &quot;reasoned&quot; out in an interview was invented by Bob Floyd who won the Turing award which means he was a computer science genius - I really doubt even he figured it out in 15 minutes which is by far the maximum time interviewers would allow you to solve a problem. People like you who pretend to be  smart are the worst interviewers because you lie to yourself about your abilities and make job candidates suffer for it.</description>
		<content:encoded><![CDATA[<p>Sorry to say vidar you&#39;re blowing hot air out some orifice! the tortoise and hare solution you claim to have &#8220;reasoned&#8221; out in an interview was invented by Bob Floyd who won the Turing award which means he was a computer science genius &#8211; I really doubt even he figured it out in 15 minutes which is by far the maximum time interviewers would allow you to solve a problem. People like you who pretend to be  smart are the worst interviewers because you lie to yourself about your abilities and make job candidates suffer for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gournew</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-4944</link>
		<dc:creator>gournew</dc:creator>
		<pubDate>Thu, 08 Apr 2010 11:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-4944</guid>
		<description>How to break the loop:&lt;br&gt;step1:&lt;br&gt;Detect  the loop using slow(p1) and first pointer(p2)&lt;br&gt;step2:-&lt;br&gt;keep one poionter (p1)there and reset pointer (p2=head)to head.&lt;br&gt;step 3:&lt;br&gt;go still both are same now make p2-&gt;next=NULL. &lt;br&gt;complete code::-&lt;br&gt;&lt;a href=&quot;http://goursaha.freeoda.com/DataStructure/LoopDetectionInLL.html&quot; rel=&quot;nofollow&quot;&gt;http://goursaha.freeoda.com/DataStructure/LoopD...&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>How to break the loop:<br />step1:<br />Detect  the loop using slow(p1) and first pointer(p2)<br />step2:-<br />keep one poionter (p1)there and reset pointer (p2=head)to head.<br />step 3:<br />go still both are same now make p2-&gt;next=NULL. <br />complete code::-<br /><a href="http://goursaha.freeoda.com/DataStructure/LoopDetectionInLL.html" rel="nofollow"></a><a href="http://goursaha.freeoda.com/DataStructure/LoopD.." rel="nofollow">http://goursaha.freeoda.com/DataStructure/LoopD..</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: axvpast</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-4861</link>
		<dc:creator>axvpast</dc:creator>
		<pubDate>Tue, 23 Feb 2010 02:45:58 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-4861</guid>
		<description>For my opinion the best solution is just extend Node by additional attribute (visited).&lt;br&gt;After that we have linear algorithm complexity without performance and resources problems. In all other cases we need more memory or more CPU time.</description>
		<content:encoded><![CDATA[<p>For my opinion the best solution is just extend Node by additional attribute (visited).<br />After that we have linear algorithm complexity without performance and resources problems. In all other cases we need more memory or more CPU time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jc</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-3197</link>
		<dc:creator>jc</dc:creator>
		<pubDate>Fri, 06 Jun 2008 16:09:01 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-3197</guid>
		<description>In the &#039;easy solution&#039; you also first need to check for a list that has 2 nodes that are in loop.</description>
		<content:encoded><![CDATA[<p>In the &#8216;easy solution&#8217; you also first need to check for a list that has 2 nodes that are in loop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-2849</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Wed, 14 May 2008 17:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-2849</guid>
		<description>Shaneal,

You&#039;re right.</description>
		<content:encoded><![CDATA[<p>Shaneal,</p>
<p>You&#8217;re right.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shaneal Manek</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-2846</link>
		<dc:creator>Shaneal Manek</dc:creator>
		<pubDate>Wed, 14 May 2008 12:51:53 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-2846</guid>
		<description>I believe you have an error in your analysis of the &#039;easy solution.&#039;

It runs in O(n^2) time, not O(n). I think since you are using an array to store the nodes already seen,for an n item list it will take take a total of 
n + (n-1) + (n-2) + ... + 1 operations, 
to determine if a given node has already been seen.

This is an arithmetic progression sums to n*(n+1)/2 = 1/2*(n^2+n) which is O(n^2) complexity.

I believe you can get an O(n) time complexity if you use a hash table to store the nodes already seen instead of an array.</description>
		<content:encoded><![CDATA[<p>I believe you have an error in your analysis of the &#8216;easy solution.&#8217;</p>
<p>It runs in O(n^2) time, not O(n). I think since you are using an array to store the nodes already seen,for an n item list it will take take a total of<br />
n + (n-1) + (n-2) + &#8230; + 1 operations,<br />
to determine if a given node has already been seen.</p>
<p>This is an arithmetic progression sums to n*(n+1)/2 = 1/2*(n^2+n) which is O(n^2) complexity.</p>
<p>I believe you can get an O(n) time complexity if you use a hash table to store the nodes already seen instead of an array.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://20bits.com/articles/interview-questions-loops-in-linked-lists/comment-page-1/#comment-1861</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Tue, 29 Apr 2008 05:35:35 +0000</pubDate>
		<guid isPermaLink="false">http://20bits.com/?p=99#comment-1861</guid>
		<description>Jim,

1) I never said it ran in constant time. I said it took constant memory, which is true.

2) &lt;tt&gt;has_loop?&lt;/tt&gt; expects a Node object to be passed in, so it should never be nil.  In a real-world situation I&#039;d of course have exception handling, but the examples were meant to be illustrative rather than complete.

Cheers,
Jesse</description>
		<content:encoded><![CDATA[<p>Jim,</p>
<p>1) I never said it ran in constant time. I said it took constant memory, which is true.</p>
<p>2) <tt>has_loop?</tt> expects a Node object to be passed in, so it should never be nil.  In a real-world situation I&#8217;d of course have exception handling, but the examples were meant to be illustrative rather than complete.</p>
<p>Cheers,<br />
Jesse</p>
]]></content:encoded>
	</item>
</channel>
</rss>
