Reversing a linked list if loop exists:

1. Find the node from which loop start by any loop finding algorithm in
linked list and keep the position of that node.

2. Unroll the loop i.e. set the last node's(last unrepeating node) next
pointer to NULL.

3. Reverse this singly linked list.

4. Change the last node's next pointer to the node corresponding to the
position we found in step1.

On Thu, Aug 23, 2012 at 8:02 PM, sulekha metta <[email protected]>wrote:

> Hi all,
>          This was asked in microsoft, question is  write a program to
> reverse a linked list.and write it's test cases.
> i got very few test cases
> 1) check if the node is null
> 2) check if there is only one node
> 3) check if there is any loop in the linked list.
>  can any one tell how to reverse a linked list if loop exits? is it
> possible?
> and  can any one add few more test cases??
>
>
> --
> Regards
> sulekha metta
> B.E computer science
> osmania university
>
>  --
> 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.

Reply via email to