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
Evaluate the following prefix expression " ++ 26 + - 1324" (Similar types can be asked)
Which file contains the definition of member functions?
What is the types of data structure?
What are the 3 control structures in programming?
How do I sort hashset?
Devise a program to sort an array using bubble sort.
What are the parts of a linked list?
How many passes are required in bubble sort?
Why do we study data structures?
Write an algorithm to show the reverse of link list?
Is hashmap an object?
What are linear and non linear data structures?
Does treemap allow null key?
Can tuple be sorted?
What is a map programming?