How can one find a cycle in the linked list? IF found how
to recognize the cycle and delete that cycle?

Answers were Sorted based on User's Feedback



How can one find a cycle in the linked list? IF found how to recognize the cycle and delete that c..

Answer / riddle

I dont think answer #8 is any recursive verion .....

Is This Answer Correct ?    1 Yes 2 No

How can one find a cycle in the linked list? IF found how to recognize the cycle and delete that c..

Answer / rajdeep...

void cycle_detect(struct node *head)
{
struct node *ptr1=head;
struct node *ptr2=head;
while(ptr1!=NULL && ptr1->next!=ptr2)
{
ptr1=ptr1->next;
}
if(ptr1->next==ptr2)
{
printf("the list contains cycle");
}
else
{
printf("the list don't contain cycle");
}
}

Is This Answer Correct ?    6 Yes 16 No

Post New Answer

More Data Structures Interview Questions

What is a pass in bubble sort?

0 Answers  


Does list maintain insertion order?

0 Answers  


Questions related to arrays, such as given a 2 integer array, find the common elements.

0 Answers   Expedia,


What do you mean by free pool?

0 Answers  


How will you explain circular linked list?

0 Answers  






What is placement new in data structures?

0 Answers  


Why is concurrenthashmap thread safe?

0 Answers  


If I try to add enum constants to a treeset, what sorting order will it use?

0 Answers  


Write program for Bubble Sort ?

0 Answers  


Tell me the difference between structure and array?

0 Answers   NIIT,


What is data structure and its classification?

0 Answers  


Describe linear probing with an example.

0 Answers  


Categories