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
What do you mean by sorting data?
Explain the implementation of an AVL tree and Binary tree.
How many sorting techniques are there?
Write a data structure for a queue.
Which sorting method is slowest?
What is the height of binary tree?
What do you mean by recursive definition?
Define threaded binary tree. Explain its common uses
What is an algorithm in coding?
Tell me is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Can you please explain the difference between string and an array?
What is the best complexity of bubble sort?
How to show internal storage representation of data structure in RDBM?
Draw the B-tree of order 3 created by inserting the following data arriving in sequence – 92 24 6 7 11 8 22 4 5 16 19 20 78
How to check array contains value or not?