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 is array and its types in data structure?

888


Define non linear data structure.

920


Explain circular linked list?

868


What exactly is data?

874


What are the issues that hamper the efficiency in sorting a file?

936


What do you mean by rehashing?

1075


Is int a data structure?

848


What is definition list?

882


Can we insert null in hashset?

992


What are the main differences between the linked list and linear array?

921


an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).

863


What do you mean by general trees?

956


List some applications of tree-data structure?

833


Design a datastructure to represent the movement of a knight on a chess board

898


What is a node in it?

882