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

How do you replace an element in an arraylist?

0 Answers  


Explain the term base case?

0 Answers  


What does stack top do?

0 Answers  


What is harvesting in agriculture?

0 Answers  


What is complexity algorithm?

0 Answers  






Explain the Array

0 Answers   Tech Mahindra,


What is the Insertion Sort Code?.

0 Answers   DELL,


Does hashset guarantee order?

0 Answers  


Classify the Hashing Functions based on the various methods by which the key value is found.

1 Answers  


Describe tree database.

0 Answers  


what is a balanced tree.

0 Answers  


Is map a collection?

0 Answers  


Categories