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
Tell me what should be done in the base case for this recursive problem?
How do you sort elements in an arraylist?
Are linked lists useful?
Tell me is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What is faster array or arraylist?
Briefly explain recursive algorithm?
Can hashmap have same key?
What is a list of lists?
What is the procedure to insert into a sorted array?
Difference between arraylist and linkedlist?
Which collection allows null values?
What does a treemap do?
How do you find the index of an element in an arraylist?
How to pass in data structure exam?
What is a property class?