<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Reversing single linked list recursively</title>
	<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/</link>
	<description>C/C++ Programming Blog</description>
	<pubDate>Fri, 25 Jul 2008 12:51:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Igor Kostic</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26854</link>
		<dc:creator>Igor Kostic</dc:creator>
		<pubDate>Wed, 25 Jun 2008 04:12:16 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26854</guid>
		<description>I' guess I'm posting in a wrong thread.
The fix is is for reverse function which is not recursive.
Sorry.</description>
		<content:encoded><![CDATA[<p>I&#8217; guess I&#8217;m posting in a wrong thread.<br />
The fix is is for reverse function which is not recursive.<br />
Sorry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Kostic</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26853</link>
		<dc:creator>Igor Kostic</dc:creator>
		<pubDate>Wed, 25 Jun 2008 04:07:44 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26853</guid>
		<description>Also interested in swaping elements of SLL and DLL (changing pointers based) and sorting the list using insertion sort after the lists are created.
Anyone worked on this...</description>
		<content:encoded><![CDATA[<p>Also interested in swaping elements of SLL and DLL (changing pointers based) and sorting the list using insertion sort after the lists are created.<br />
Anyone worked on this&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Kostic</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26852</link>
		<dc:creator>Igor Kostic</dc:creator>
		<pubDate>Wed, 25 Jun 2008 04:01:49 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26852</guid>
		<description>I guess I'm to tired. I ment DLList but you have it already here.
Keep up the good work.</description>
		<content:encoded><![CDATA[<p>I guess I&#8217;m to tired. I ment DLList but you have it already here.<br />
Keep up the good work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Igor Kostic</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26851</link>
		<dc:creator>Igor Kostic</dc:creator>
		<pubDate>Wed, 25 Jun 2008 03:52:44 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26851</guid>
		<description>There is a typo in the code. Just change 

void reverse(struct node** headRef)
to
void reverse(struct Node** headRef)

and in main use
reverse(&#38;h);
instead of
h = recreverse(h);

It runs now.

I'm interested how is it possible to implement function that will reverse the order of the elements of single linked list in one pass without recursion and helper structures.

Anyone?

BTW. Example is very nice.</description>
		<content:encoded><![CDATA[<p>There is a typo in the code. Just change </p>
<p>void reverse(struct node** headRef)<br />
to<br />
void reverse(struct Node** headRef)</p>
<p>and in main use<br />
reverse(&amp;h);<br />
instead of<br />
h = recreverse(h);</p>
<p>It runs now.</p>
<p>I&#8217;m interested how is it possible to implement function that will reverse the order of the elements of single linked list in one pass without recursion and helper structures.</p>
<p>Anyone?</p>
<p>BTW. Example is very nice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edna Umali</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26682</link>
		<dc:creator>Edna Umali</dc:creator>
		<pubDate>Thu, 05 Jun 2008 13:22:34 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26682</guid>
		<description>i tried but it did not run</description>
		<content:encoded><![CDATA[<p>i tried but it did not run</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26449</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Thu, 08 May 2008 07:14:07 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-26449</guid>
		<description>Why static??</description>
		<content:encoded><![CDATA[<p>Why static??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ponnada</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-24298</link>
		<dc:creator>ponnada</dc:creator>
		<pubDate>Wed, 30 Apr 2008 04:45:51 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-24298</guid>
		<description>aftab,
I'd not given complete code (only reverse function I gave) not sure how you made a complete piece of code (by writing yours or plugging from other artilces) and not sure how you run, here I'm gibing complete code
&lt;a href="http://www.openasthra.com/wp-content/uploads/sll_reverse_complete.c" rel="nofollow"&gt;complete code&lt;/a&gt;
I'm not facing any problems, let me know
 if you face any problems further</description>
		<content:encoded><![CDATA[<p>aftab,<br />
I&#8217;d not given complete code (only reverse function I gave) not sure how you made a complete piece of code (by writing yours or plugging from other artilces) and not sure how you run, here I&#8217;m gibing complete code<br />
<a href="http://www.openasthra.com/wp-content/uploads/sll_reverse_complete.c" rel="nofollow">complete code</a><br />
I&#8217;m not facing any problems, let me know<br />
 if you face any problems further</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aftab</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-24291</link>
		<dc:creator>aftab</dc:creator>
		<pubDate>Tue, 29 Apr 2008 09:05:06 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-24291</guid>
		<description>I tried  the piece of code by "ponnada"  on a solaris platform just to see the result......
Segmentation Fault(coredump)
aftab</description>
		<content:encoded><![CDATA[<p>I tried  the piece of code by &#8220;ponnada&#8221;  on a solaris platform just to see the result&#8230;&#8230;<br />
Segmentation Fault(coredump)<br />
aftab</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ponnada</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-22382</link>
		<dc:creator>ponnada</dc:creator>
		<pubDate>Thu, 17 Apr 2008 13:56:22 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-22382</guid>
		<description>Hi Aksu,
&#62;The implementation crashes if the list is empty
Yes, it crashes for empty list, it was just an overlook, and simple check should suffice to stop that
&#62;does not work in a multithreaded system
I didn't claim that it works for multithread env, if I would have intention of multithread env, i would have not used static variables.. surprisingly your version also suffers from empty list crash scenario.
Anyways thanks for pointing out that bug.</description>
		<content:encoded><![CDATA[<p>Hi Aksu,<br />
&gt;The implementation crashes if the list is empty<br />
Yes, it crashes for empty list, it was just an overlook, and simple check should suffice to stop that<br />
&gt;does not work in a multithreaded system<br />
I didn&#8217;t claim that it works for multithread env, if I would have intention of multithread env, i would have not used static variables.. surprisingly your version also suffers from empty list crash scenario.<br />
Anyways thanks for pointing out that bug.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aksu</title>
		<link>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-22381</link>
		<dc:creator>Aksu</dc:creator>
		<pubDate>Thu, 17 Apr 2008 08:37:09 +0000</pubDate>
		<guid>http://www.openasthra.com/c-tidbits/reversing-single-linked-list-recursively/#comment-22381</guid>
		<description>I can only guess that the previous comments were ironic...

The implementation crashes if the list is empty, does not work in a multithreaded system, and is far from elegant.

Consider:

/* helper func */
struct Node* reverse(struct Node* current, struct Node* previous)
    {
    struct Node* next = current-&#62;next;
    current-&#62;next = previous;
    if (next)
        {
        return reverse(next, current);
        }
    return current;
    }

struct Node* reverse(struct Node* aHead)
    {
    if (aHead) 
        {
        return reverse(aHead, NULL);
        {
    return NULL;
    }</description>
		<content:encoded><![CDATA[<p>I can only guess that the previous comments were ironic&#8230;</p>
<p>The implementation crashes if the list is empty, does not work in a multithreaded system, and is far from elegant.</p>
<p>Consider:</p>
<p>/* helper func */<br />
struct Node* reverse(struct Node* current, struct Node* previous)<br />
    {<br />
    struct Node* next = current-&gt;next;<br />
    current-&gt;next = previous;<br />
    if (next)<br />
        {<br />
        return reverse(next, current);<br />
        }<br />
    return current;<br />
    }</p>
<p>struct Node* reverse(struct Node* aHead)<br />
    {<br />
    if (aHead)<br />
        {<br />
        return reverse(aHead, NULL);<br />
        {<br />
    return NULL;<br />
    }</p>
]]></content:encoded>
	</item>
</channel>
</rss>
