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

Evaluate the following prefix expression " ++ 26 + - 1324" (Similar types can be asked)

966


Which file contains the definition of member functions?

927


What is the types of data structure?

1016


What are the 3 control structures in programming?

914


How do I sort hashset?

893


Devise a program to sort an array using bubble sort.

1032


What are the parts of a linked list?

1033


How many passes are required in bubble sort?

813


Why do we study data structures?

921


Write an algorithm to show the reverse of link list?

856


Is hashmap an object?

882


What are linear and non linear data structures?

852


Does treemap allow null key?

851


Can tuple be sorted?

911


What is a map programming?

943