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 / monti

bool find_cycle(Node* head){
Node* ptr1 = head;
Node* ptr2 = head;

while(ptr1 != NULL && ptr2 != NULL && ptr2->next != NULL){
if(ptr1 == ptr2){
printf("\nClycle present in thr LinkList\n");
return true;
}
ptr1 = prt1->next;
ptr2 = ptr2->next->next;
}
return false;
}

Is This Answer Correct ?    36 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is bubble sort faster than selection sort?

791


Why do we use hashmap?

989


You are given a singly linked list. How would you find out if it contains a loop or not without using temporary space?

1052


What is modcount in hashmap?

820


What are the disadvantages of circular list?

908


which notations are used in evaluation of arithmetic expressions using prefix and postfix forms?

958


How would you dynamically allocate a one-dimensional and two-dimensional array of integers?

937


Explain what are the major data structures used in the network data model?

987


What is the best complexity of bubble sort?

848


Is binary tree a bst?

862


What are the advantages of bubble sort?

909


How does a dynamic array work?

812


What is an iterative algorithm?

907


Write a Program for Delete an element from a doubly linked list.

845


What is adt and its advantages?

953