Why the output is printing four times? Please Reply ASAP as I have already asked this doubt twice and didn't get any response!

hello @vanshikasharma1645

check here->

u were printng output in each iteration of while loop thats why u were getting output 4 times.

if cycle found then print found and exit
otherwise continue doing same step.
in the end of while print not found becuase control will reach to end only if cyle is not present.

btw there is mistake in ur insert function, using that algo u will never be able to build circular list.

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.