How can one find a cycle in the linked list? IF found how
to recognize the cycle and delete that cycle?
Answer Posted / 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 View All Answers
What are the advantage of collection classes over arrays?
What is the height of binary tree?
What is java priority queue?
What is scalar data type?
Write a program to reverse a link list.
Can a hashmap have duplicate keys?
Why quicksort is faster?
How to use appendNode() in linkedlist()?
Define forest?
What is selection in an algorithm?
What is range search?
List out the advantages of using a linked list?
What are the classification of data structures?
Calculate the efficiency of sequential search?
Explain the Stack