It's possible if u modify the definition of the node itself. add one variable ..let's say:IsVisited for every node. initialized to false.And while traversing the list make it true. Now traverse it and check whether head->next is true or false. If true return .
But in this process original Linked list will be destroyed. This process will use only one pointer..i.e.head pointer. Regards, Sayan On Thu, Dec 8, 2011 at 6:34 PM, Ankur Garg <ankurga...@gmail.com> wrote: > U cant create any new ptrs .Just use this ptr :) > > > On Thu, Dec 8, 2011 at 6:30 PM, Prem Krishna Chettri > <hprem...@gmail.com>wrote: > >> Ofcourse we can.. >> >> U knw the head address now U start visit the list what is the big >> deal?? Jst u gotto create two pointer say fast and slow with two diff speed >> of action.. >> >> On Thu, Dec 8, 2011 at 6:27 PM, Ankur Garg <ankurga...@gmail.com> wrote: >> >>> Can we detect if a loop is present in Linked List if only head ptr is >>> given >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.