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

Should I use hashmap or hashtable?

0 Answers  


What is time complexity of quick sort?

0 Answers  


What is return map?

0 Answers  


Define level of the tree?

0 Answers  


Can you change size of array once created?

0 Answers  






What is the Insertion Sort Code?.

0 Answers   DELL,


What do you know about different sorting algorithms?

0 Answers   Zomato,


Does treeset allow duplicates?

0 Answers  


What are some of the best practices relating to the java collection framework?

0 Answers  


How do stacks work?

0 Answers  


What is difference between hashset and treeset?

0 Answers  


Can we store null in arraylist?

0 Answers  


Categories