Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the advantage of collection classes over arrays?

894


What is the height of binary tree?

985


What is java priority queue?

969


What is scalar data type?

996


Write a program to reverse a link list.

931


Can a hashmap have duplicate keys?

927


Why quicksort is faster?

849


How to use appendNode() in linkedlist()?

1089


Define forest?

976


What is selection in an algorithm?

873


What is range search?

890


List out the advantages of using a linked list?

854


What are the classification of data structures?

925


Calculate the efficiency of sequential search?

931


Explain the Stack

966