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
How do you sort large data?
What are the disadvantages of using collection classes over arrays?
What is the use of sorting the data?
Is unordered_map a hash table?
What are the applications of b-tree?
Can we extend an array after initialization?
Can we store a string and integer together in an array?
What do you mean by sorting?
How dynamic arrays are created?
What is the default capacity of hashmap?
What is complexity of quicksort?
Why do we use binary search?
Can we modify final arraylist?
Is boolean a data type?
Is quicksort greedy algorithm?