node * reverse(node *head)
{
if(head->next)
{
node * temp=reverse(head->next);
head->next->next=head;
head->next=NULL;
return temp;
}
return head;
}
On Sun, Jul 17, 2011 at 4:57 PM, Piyush Sinha <[email protected]>wrote:
> *node *reverse(node *head)
> {
> if(head==NULL)
> return head;
> if(head->next==NULL)
> return head;
> node *temp = reverse(head->next);
> head->next->next = head;
> head->next = NULL;
> return (temp);
> }*
>
>
> On Sun, Jul 17, 2011 at 4:30 PM, Anika Jain <[email protected]>wrote:
>
>> initial call to this will be rev(head);
>>
>>
>> On Sun, Jul 17, 2011 at 4:28 PM, Anika Jain <[email protected]>wrote:
>>
>>> node *listing::rev(node *p)
>>> {
>>> if(p->next==NULL)
>>> {
>>> head=p;
>>> return p;
>>> }
>>> else
>>> {
>>> node *t=rev(p->next);
>>> t->next=p;
>>> p->next=NULL;
>>> tail=p;
>>> return p;
>>>
>>> }
>>> }
>>>
>>> On Sun, Jul 17, 2011 at 3:21 PM, Nishant Mittal <
>>> [email protected]> wrote:
>>>
>>>> void rev_recursion(NODE **head)
>>>> {
>>>> if(*head==NULL)
>>>> return;
>>>> NODE *first, *rest;
>>>> first=*head;
>>>> rest=first->next;
>>>> if(!rest)
>>>> return;
>>>> rev_recursion(&rest);
>>>> first->next->next=first;
>>>> first->next=NULL;
>>>> *head=rest;
>>>>
>>>> }
>>>>
>>>> On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla <
>>>> [email protected]> wrote:
>>>>
>>>>> struct node *reverse_recurse(struct node *start)
>>>>> {
>>>>> if(start->next)
>>>>> {
>>>>> reverse_recurse(start->next);
>>>>> start->next->next=start;
>>>>> return(start);
>>>>> }
>>>>> else
>>>>> {
>>>>> head=start;
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> in main
>>>>>
>>>>> if(head)
>>>>> {
>>>>> temp = reverse_recurse(head);
>>>>> temp->next =NULL;
>>>>> }
>>>>>
>>>>> "head and temp are global"
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta
>>>>> <[email protected]>wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I was trying to accomplish this task with the following call , header
>>>>>> = ReverseList(header)
>>>>>>
>>>>>> I don't want to pass tail pointer or anything and just want that i get
>>>>>> a reversed list with new header properly assigned after this call. I
>>>>>> am getting issues in corner conditions like returning the correct node
>>>>>> to be assigned to header.
>>>>>>
>>>>>> Can anyone give an elegant solution with above requirement? Since it
>>>>>> is with recursion, please test for multiple scenarios (empty list, one
>>>>>> node list, twe nodes
>>>>>
>>>>>
>>>>>
>>>>>> list etc) before posting your solution. In case
>>>>>> of empty list, the procedure should report that.
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Navneet
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to [email protected].
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected].
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> best wishes!!
>>>>> Vaibhav Shukla
>>>>> DU-MCA
>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> *Piyush Sinha*
> *IIIT, Allahabad*
> *+91-7483122727*
> * <https://www.facebook.com/profile.php?id=100000655377926> "NEVER SAY
> NEVER"
> *
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.