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 is array and its types in data structure?
Define non linear data structure.
Explain circular linked list?
What exactly is data?
What are the issues that hamper the efficiency in sorting a file?
What do you mean by rehashing?
Is int a data structure?
What is definition list?
Can we insert null in hashset?
What are the main differences between the linked list and linear array?
an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).
What do you mean by general trees?
List some applications of tree-data structure?
Design a datastructure to represent the movement of a knight on a chess board
What is a node in it?