sir in circular list ouetion
the question is wrong
user input numer while making the linked list
he will think that every number shoud go to tail not make any loop how i solve i know the algorithm but how i apply
Please about question
The algorithm is :
- Detect Loop using Floyd’s Cycle detection algo and get the pointer to a loop node.
- Count the number of nodes in loop. Let the count be k.
- Fix one pointer to the head and another to kth node from head.
- Move both pointers at the same pace, they will meet at loop starting node.
- Get pointer to the last node of loop and make next of it as NULL.
Dry run this code you will get to know how to implement https://ide.codingblocks.com/s/17565
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance,you still have some questions or not find the answers satisfactory, you may reopen
the doubt.