Try a dry run on the following linked list 1->2->3->4->5->6->Null
head is a global variable; The recursion will take place till 6 and assign head address of 6; then it will first change 5->6->(back to 5) [root->next->next = root] when it will be back to 4, change 4->5->(back to 4) . at this stage the linked list is something like this: 1->2->3->4<=>5<-6; [4<=>5 == 4->5 and 5->4] . . this will continue till 1, 1->2->(back to 1) But there is this glinch, 1 should point to NULL now, which I think is not happening. There is a return(root) in the final encounter. use that like p=reverse_recursive(head); p->next= NULL; I hope you get my point. On 5 August 2011 23:33, Rajeshwar Patra <[email protected]> wrote: > mynode* reverse_recurse(mynode *root) > > { > > if(root->next!=(mynode *)0) > > { > > reverse_recurse(root->next); > > root->next->next=root; > > return(root); > > } > > else > > { > > head=root; > > } > > } > how does it reverses the singly linked list > > -- > *Rajeshwar Patra,* > *MCA final year,* > *Nit Durgapur* > > -- > 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. > -- ___________________________________________________________________________________________________________ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers <=> Save Trees -- 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.
