How can one find a cycle in the linked list? IF found how
to recognize the cycle and delete that cycle?
Answers were Sorted based on User's Feedback
Answer / riddle
I dont think answer #8 is any recursive verion .....
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / 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 |
Should I use hashmap or hashtable?
What is time complexity of quick sort?
What is return map?
Define level of the tree?
Can you change size of array once created?
What is the Insertion Sort Code?.
What do you know about different sorting algorithms?
Does treeset allow duplicates?
What are some of the best practices relating to the java collection framework?
How do stacks work?
What is difference between hashset and treeset?
Can we store null in arraylist?