How can I detect that whether a singly linked-list has loop or not?? If it has loop then how to find the point of origination of the loop i.e. the node from which the loop
bool FindLoop(struct node *head) { struct node *current1,*current2; current1=head; current2=head; while(current1!=NULL && current2!= NULL && current2->next!= NULL) { current1=current1->next; current2=current2->next->next; if(current1==current2) { return true; } } return false; }